@fjfranco, even if stretching it by one order of magnitude and running the Julia REPL on a cell phone it wasn’t enough time to get an espresso shot ready…
It doesn’t seem Julia is exceptionally fast in this example (Even though it has the advantage of working in place). I find Julia having in place sort() to be a nice advantage. But that’s hardly the bottleneck here.
Is sort() written in Julia? Was that your point? Having the sort() function written in a dynamic language and be fast (Same scale) as c? If so, it is indeed impressive.
Yes, this is ~20% faster and nice to know about that package!
However, it seems more unstable on my cellphone: sometimes the process aborts saying “Killed” or it can even abort the Julia REPL.
Try this and MATLAB will not be faster any more. Future implementations of other algorithms into ThreadsX can get even faster. The Multithreading hero, aka @tkf, may give us more insights.
using ThreadsX
julia> @time ThreadsX.sort!(rand(Float64, 100_000_000));
3.376360 seconds (4.29 M allocations: 1.973 GiB)
MATLAB (R2020a) for reference (multithreaded by default):
tic
sort(rand(100000000,1));
toc
Elapsed time is 3.731379 seconds.
I wish, in some way, all allocating functions would support given a pre allocated buffers on the function call.
To the least the in place flavors.
It means the user will be able to create a non allocating paradigm (Pre allocating all at the beginning of the program and from there just recycling the buffers).
It will probably also help the GC, right?
Maybe something to think about for Julia 2.0.
It can become very important in production.