Closed
Description
std::rand::random
is quite slow, since it has to do a TLD look-up to find the task_rng
, and only then generate the random number. The docs should mention that if random
is called repeatedly, one should do a single look-up via the task_rng()
function, and then call the Rng
methods directly.
E.g.
for x in foo.mut_iter() {
*x = rand::random()
}
// would be faster as
let mut rng = rand::task_rng();
for x in foo.mut_iter() {
*x = rng.gen();
}
Metadata
Metadata
Assignees
Labels
No labels