Try
    @edit randperm(10)
and see for yourself.

My bet is that you could speed it up by generating all the random numbers 
you'll need in one go, rather than generating them one-by-one. Want to give it 
a shot?

--Tim

On Friday, January 22, 2016 02:54:51 PM Brian Lucena wrote:
> 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,
> B

Reply via email to