Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use newer
slices.Sort
in pruneDuplicates
The new `slices.Sort` introduced in Go 1.21 [1] is faster than the old `sort.Slice` approach. func BenchmarkSort(b *testing.B) { array := []uint64{0, 42, 10, 8} b.Run("sort.Slice", func(b *testing.B) { for i := 0; i < b.N; i++ { sort.Slice(array, func(i, j int) bool { return array[i] < array[j] }) } }) b.Run("slices.Sort", func(b *testing.B) { for i := 0; i < b.N; i++ { slices.Sort(array) } }) } goos: linux goarch: amd64 pkg: github.com/FastFilter/xorfilter cpu: AMD Ryzen 7 PRO 4750U with Radeon Graphics BenchmarkSort/sort.Slice-16 4290086 284.0 ns/op 56 B/op 2 allocs/op BenchmarkSort/slices.Sort-16 62395050 19.53 ns/op 0 B/op 0 allocs/op PASS ok github.com/FastFilter/xorfilter 3.739s [1]: https://pkg.go.dev/slices#Sort Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
- Loading branch information