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

Peter peter at pblackman.plus.com
Wed Dec 7 14:54:21 CET 2011


Graeme,

I would recommend using Marsaglia's XORShift.
Blisteringly fast, high quality statistically, and very easy to implement.

http://en.wikipedia.org/wiki/Xorshift


Regards,
Peter


On 07/12/11 13:10, Graeme Geldenhuys wrote:
> On 7 December 2011 14:54, Jonas Maebe  wrote:
>    
>> That's correct. We use the mersenne twister, Delphi probably a linear
>> congruential generator. The mersenne twister has a much larger period.
>>      
> OK thanks for the info. This is a serious performance hit, but I
> understand that the FPC implementation is different. Does FPC have a
> faster (comparable to Delphi) version of Random() too?
>
> @Michael,
> Should the FPC docs maybe mention the fact that the FPC version is
> considerably slower that Delphi (with an explanation why of course) -
> purely for the purpose of informing those porting code from Delphi to
> FPC. The original code in tiOPF is so slow, I almost thought the
> program froze - thus making that code really unusable in an
> application. Luckily that code will normally not be used in a real app
> though. Delphi developers wanting to move to FPC should really be
> warned about this, and use Random() sparingly.
>
>    




More information about the fpc-pascal mailing list