-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Benchmarking 5 different methods:
using TupleTools, Plots, StaticArrays, SortingNetworks
times1 = zeros(25)
times2 = zeros(25)
times3 = zeros(25)
times4 = zeros(25)
times5 = zeros(25)
for N in 1:25
print(N)
t = tuple(rand(N)...)
times1[N] = @belapsed TupleTools.sort(t)
times2[N] = @belapsed Tuple(sort!(collect(t)))
times3[N] = @belapsed sort!(MVector(t)).data
times4[N] = @belapsed sort(SVector(t)).data
times5[N] = @belapsed swapsort(t)
end
plot([times1 times2 times3 times4 times5], yaxis=:log)TupleTools.sort only has advantage at very small tuples (<=6) so my proposal is to change the method name to tuplesort and only apply it for small tuples. For such a small size it could be possible to generate fully performant codes rather than the merging algorithm.
Edit: added SortingNetworks.swapsort which is even faster than TupleTools.sort
Metadata
Metadata
Assignees
Labels
No labels
