Hello.

Why is rand(rng) ten times slower than rand() ?

See code below:

julia> using Random

julia> rng = MersenneTwister(12345);

julia> function test()

t0=time()

x=0.0;

for k=1:100000000

x+=rand(rng)

end

x,time()-t0

end

test (generic function with 1 method)

julia> test()

(4.999454956309856e7, 8.787218809127808)

julia> function test()

t0=time()

x=0.0;

for k=1:100000000

x+=rand()

end

x,time()-t0

end

test (generic function with 1 method)

julia> test()

(5.000040368583618e7, 0.8501379489898682)