Speed of Random Numbers
Giovanni Di Maria
calimero22 at yahoo.it
Sat Aug 3 17:47:46 UTC 2019
On Saturday, 3 August 2019 at 17:44:44 UTC, lithium iodate wrote:
> On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria
> wrote:
>> [...]
>
> First off you could try to use a faster RNG engine than the
> default. The easiest way is to define a variable containing it
> and passing it to the functions each time.
>
> auto rng = Xorshift(1234);
> randomNumber = uniform!uint(rng);
>
> This basic change approximately halved the 5 seconds your
> original example needs on my computer.
> Another simple approach that I have tried is simply hashing the
> iterator using a fast hash function.
> With xxHash32 I got the time down to 0.25 seconds. I also tried
> xxHash64 and FNV1a but they were not faster in my quick test.
Thank you very much Lithium Iodate
Now i will try it.
I let know you.
Thank you
Giovanni
More information about the Digitalmars-d-learn
mailing list