No need for root in Android, just follow this great post.
Even faster
using SortingAlgorithms
@time sort!(rand(Float64, 10000000), alg=RadixSort)
Try the above. It’s faster.
Faster, I suspect
using SortingAlgorithms
@time sort!(rand(Float64, 100_000_000), alg=RadixSort)
Because Julia people don’t quit(); the exit() gracefully.
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.
That’s what happens when you run out of memory on Linux.
radixsort does use double the memory.
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.
Tagging @tro3 and @stillyslalom:
julia> using Unitful, Unitful.DefaultSymbols julia> 800mV/53.55μA 14.939309056956116 mV μA^-1 julia> uconvert(kΩ, ans) 14.939309056956116 kΩ
Even better with some syntactical sugar
julia> using Unitful, Unitful.DefaultSymbols
julia> 800mV/53.55μA |> kΩ
14.939309056956116 kΩ
Faster, I suspect
using SortingAlgorithms @time sort!(rand(Float64, 100_000_000), alg=RadixSort)
Future implementations of other algorithms into
ThreadsX
can get even faster.
Yes, radix sort is great. So let’s parallelize it
julia> using SortingAlgorithms, ThreadsX, ParallelRadixSort
julia> x = rand(Float64, 100_000_000);
julia> @time sort(x, alg = RadixSort);
3.495047 seconds (18 allocations: 1.490 GiB)
julia> @time sort(x, alg = ThreadsX.QuickSort);
2.001733 seconds (4.22 M allocations: 1.895 GiB, 5.03% gc time)
julia> @time sort(x, alg = ParallelMSDRadixSort);
1.174623 seconds (134.32 k allocations: 1.496 GiB, 9.39% gc time)
julia> Threads.nthreads()
8
(All @time
s are not the first run since ParallelMSDRadixSort
seems to have a large compilation overhead ATM.)
Julia, you are my only hope to escape from the heavily templated clutches of evil C++ Emperor with an awful syntax!
Julia: Code that actually composes
Yes, radix sort is great. So let’s parallelize it
nice. I see the code is using MSD radix sort which only works if the data is “balanced” which happens to be the case for random data like this.
I would be interested in skewed data sorting with ParallelRadixsort!