[fpc-pascal] Why is Random(255) some 529x slower compared to Delphi 7?

Jürgen Hestermann juergen.hestermann at gmx.de
Wed Dec 7 18:31:03 CET 2011


Florian Klaempfl schrieb:
 > Well, once we thought we try to do things better than Delphi ;) Some
 > people, I think John Lee, asked for a better random in FPC years ago so
 > Jonas implemented a MT.

I think there are two very different approaches. I wrote a small tool 
for testing network performance that simply generates a file with random 
numbers. I used random() for the data because I wanted to avoid any 
possible compression. There is no need to have a *real* random number in 
this case. I always wondered, why this program reported slightly faster 
network transfer in Delphi than in Lazarus/FPC but now I now why. Here 
it is a bad thing that the calculation of the random numbers impacts the 
speed calculation. IMO the generation of numbers should be much faster 
than 100 MB/s but it already delays the whole process.

A completely different thing is statistics. Then you realy need a good 
random() function. In this case the quality of the numbers is much more 
important than speed.

But now we have a fast random() function in Delphi and a statistical 
good one in FPC but none of them has both.



More information about the fpc-pascal mailing list