Closed sunhay closed 6 years ago
The math/bits library now provides some pretty quick LeadingZeros64 & TrailingZeros64 functions.
LeadingZeros64
TrailingZeros64
sunny.klair:scratch $ go test -bench=. goos: darwin goarch: amd64 pkg: github.com/dgryski/go-bits BenchmarkCtzFast-4 1000000000 2.02 ns/op BenchmarkGoMathBitsTrailing-4 2000000000 1.09 ns/op BenchmarkClzFast-4 1000000000 2.17 ns/op BenchmarkGoMathBitsLeading-4 2000000000 1.15 ns/op PASS ok workspace/scratch 9.232s
https://gist.github.com/sunhay/4671ddbff6ec9a1f911ae58bde7cf4a6
The benchmark is invalid but the patch is fine.
I think I fixed the benches (out of curiosity for what was wrong). Cheers, and thanks.
The math/bits library now provides some pretty quick
LeadingZeros64
&TrailingZeros64
functions.https://gist.github.com/sunhay/4671ddbff6ec9a1f911ae58bde7cf4a6