1. Home
  2. Computing & Technology
  3. Delphi Programming
Zarko Gajic
Zarko's Delphi Programming Blog

By Zarko Gajic, About.com Guide to Delphi Programming

Challenge Results - Fastest Delphi Unique Random Number Generator

Tuesday June 16, 2009
in Delphi Challenges :: unique Random Numbers Delphi Challenge Here's the list of the accepted entries. 13 entries were accepted before initial results were published.

The winner (for the moment) is Patrick van Logchem with the fastest entry! 10 fame and glory points!!

Read the full article to find out who (you?) submitted accepted entries: Fastest Unique Random Number Generator Delphi Challenge Results

Here's an interesting comment sent by Jim McKeeth

Notes about the contest:

Judging criteria:

  1. Solve problem
  2. No memory leaks
  3. Clean and simple
  4. No unnecessary code lines
  5. Speed
  6. Subjective judgment of code

Observations:

  1. The article provides the array length and max value even though the procedure signature allows for variable lengths and values.
    • Is this (length=100 & maxValue=1000) the only test case?
    • Can we optimize for these parameters?
    • Do we need to test for incorrect parameters?
    • Can we eliminate the Int64 for Integer since the test case does not require it, thus improving performance?
  2. No unnecessary code lines is rather subjective. Possible meanings:
    • The extreme would be putting all code on one line.
    • Eliminate all tests and unlikely code paths.
    • No blank lines?
    • Favor simplicity over robustness & ease of readability?
  3. How random is random?
    • The randomness is not specified, nor the method to use.
    • Is Delphi's built in random generation system sufficient?
    • Is building our own random algorithm necessary or even allowed?
    • Is previously generated random numbers sufficient?
  4. How is speed measured?
    • Is the runtime calculated through code analysis?
    • Will the target system have multiple cores? (Should we thread?)
    • What the time vs. space trade-offs can be made for better speed?
    • Pre-generate random tables based on the constant nature of test?

Here's mine (short) reply:

1) Yes, the array is an open array, but the size of the array is determined by the "preparation" code presented in the challenge call.
2) "No unnecessary code lines" basically means that if you have a section of code that can be turned into a function or a procedure - do it.
3) Delphi Randomize and Random functions are random enough.
4) Speed is measured using the high precision timing class, TStopWatch, all entries tested on the same machine.

In general, Delphi code challenges are designed with the "having fun" idea in mind - for beginners to learn something by exploring code made by those that are no longer beginners :)

Related:

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.