19 Mar
2015
19 Mar
'15
4:03 p.m.
Andrey Semashev wrote:
Looking at Boost.Random, creating RNG involves seed generation, which is probably one or several syscalls, let alone any possible resource allocations.
Creating what type of RNG?
This has to be done on each call to shuffle, if I understand correctly.
Well, it depends, you can keep the URNG around if you like. You don't have to recreate it before each call.
Compare that with rand(), which is presumably purely computational and never fails.
I would expect rand() to take a lock (or use an atomic compare/exchange) under implementations that don't make it thread-specific, so it should be slower than a simple local RNG. Even a thread-local rand() should be slightly slower, in principle.