Uhm… but there is something tricky here.
I was using simply rand()
to generate random numbers, but to add the possibility of using optionally StableRNGs
I have to use rand(rng)
. I changed the code to do that, but the problem is that now it allocates memory:
julia> import Random
julia> rand()
0.30815646522353957
julia> @allocated rand()
0
julia> rng = Random.MersenneTwister(1);
julia> rand(rng)
0.23603334566204692
julia> @allocated rand(rng)
16
Thus, to have the option of passing a different rng
to rand()
for some reason it allocates memory even if the option is the default one (and, as I mentioned, I need to generate tenths of thousands of random numbers, so this is really an issue, the code was free from allocations without that).
Edit: Well if I declare rng
as constant, that allocation goes away. I will see if I can adapt that to my case.