On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria wrote:
Do you know other faster functions or methods to generate random numbers?

For me the "goodness of random" is NOT important.

Thank you very much
GIovanni Di Maria

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.

Reply via email to