Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting could be much faster #1254

Open
jw3126 opened this issue May 16, 2024 · 0 comments
Open

Sorting could be much faster #1254

jw3126 opened this issue May 16, 2024 · 0 comments

Comments

@jw3126
Copy link
Contributor

jw3126 commented May 16, 2024

using SortingNetworks: swapsort
using StaticArrays

for N in 5:10
    @show N
    @btime sort($v) setup=(v = SVector{$N}(rand($N)))
    println("swapsort")
    @btime swapsort($v) setup=(v = SVector{$N}(rand($N)))
end
N = 5
sort
  7.938 ns (0 allocations: 0 bytes)
swapsort
  2.000 ns (0 allocations: 0 bytes)
N = 6
sort
  12.933 ns (0 allocations: 0 bytes)
swapsort
  2.190 ns (0 allocations: 0 bytes)
N = 7
sort
  20.211 ns (0 allocations: 0 bytes)
swapsort
  2.920 ns (0 allocations: 0 bytes)
N = 8
sort
  23.454 ns (0 allocations: 0 bytes)
swapsort
  3.460 ns (0 allocations: 0 bytes)
N = 9
sort
  28.281 ns (0 allocations: 0 bytes)
swapsort
  4.570 ns (0 allocations: 0 bytes)
N = 10
sort
  33.484 ns (0 allocations: 0 bytes)
swapsort
  5.280 ns (0 allocations: 0 bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant