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

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Wed Dec 7 14:40:02 CET 2011



On Wed, 7 Dec 2011, 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.

A good point.

Please add an entry in the bug tracker, or it is likely I will forget :/

Michael.



More information about the fpc-pascal mailing list