I am running a simulation that requires me to generate random permutations 
of size 300 million.  I would ideally like to run this generation in a loop 
10K or 100K times. I am surprised that randperm is not faster in Julia than 
it is.  It seems to be considerably slower than the equivalent in R (and R 
is clearly not known for speed)  :) 

In Julia:

*julia> **@time asd=randperm(300000000)*

 43.437829 seconds (6 allocations: 2.235 GB, 0.01% gc time)

*300000000-element Array{Int64,1}:*


In R


> start = Sys.time()

> asd = sample(300000000)

> Sys.time()-start

Time difference of 23.27244 secs

Julia seems to be twice as slow!

Any thoughts on why that is?  Does randperm use the "knuth shuffle" or does 
it use some other algorithm.

Thanks,
Brian

Reply via email to