Closed
Description
Instances of Random
have a seed. The seed can be explicitly set on creation (via seed:
), or it can be generated from current timestamp (via new
). I wanted to see how much slower is to generate the seed, so wrote this benchmark:
{
[ Random new ].
[ Random seed: 7 ].
} collect: #bench.
But discovered that new
was faster than seed:
, and it doesn't make sense:
new
: 549,165 per secondseed:
295,684 per second
What happens is that Random seed: 7
first initializes the instance with a timestamp-based seed, and immediately after overrides it with the explicitly set.
This is in Pharo 12 and 13. I have a PR to fix it.
Activity