dgryski / go-tsz

Time series compression algorithm from Facebook's Gorilla paper
BSD 2-Clause "Simplified" License
538 stars 67 forks source link

Use golang math/bits leading & trailing zero count functions #20

Closed sunhay closed 6 years ago

sunhay commented 6 years ago

The math/bits library now provides some pretty quick LeadingZeros64 & TrailingZeros64 functions.

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

dgryski commented 6 years ago

The benchmark is invalid but the patch is fine.

sunhay commented 6 years ago

I think I fixed the benches (out of curiosity for what was wrong). Cheers, and thanks.