[fpc-pascal] Why is Random(255) some 529x slower compared to Delphi 7?
Vinzent Höfler
JeLlyFish.software at gmx.net
Fri Dec 9 23:18:27 CET 2011
On Thu, 08 Dec 2011 10:52:01 +0100, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:
> On 8 December 2011 11:33, Henry Vermaak wrote:
>>
>> I agree, quality first.
>
> I would normally agree with that. But such huge magnitudes slower
> (20ms vs 10585ms) on a new Quad-Core type system? That just seems a
> bit excessive, and considering most use cases are not even for
> statistical type applications.
Well, considering that the MT is a very bad choice as PRNG for a stream-
cipher (even if it's never used in "production code", it still gives me the
creeps), I'd say, your use case isn't the typical one, either. ;)
In my case I needed a thread-safe version, so may I request that
System.Random() shall be protected against concurrent access - making it
even slower?
I mean, using your own random generator for whatever reason (statistical
properties, cryptographically strong, lightning fast) isn't exactly rocket
science. ;)
<http://stop-me.svn.sourceforge.net/viewvc/stop-me/trunk/src/lfsr.pas?revision=53&view=markup>
Especially because you could speed-up your code alone by using the 64
random bits you are actually getting from the Random() call instead of
generating a stream of 512 bits for each single character. ;)
So, to come to a conclusion, I do not see any reason why the current
implementation of System.Random() shall be changed.
Vinzent.
More information about the fpc-pascal
mailing list