golang / geo

S2 geometry library in Go
Apache License 2.0
1.69k stars 182 forks source link

math/bits benchmarks #36

Closed buth closed 6 years ago

buth commented 6 years ago

Hey all. I recently opened a pull request that removed some of the redundancies with Go 1.9's math/bits package. Addressing some of the feedback there, I've written a few benchmarks to demonstrate that there is indeed a performance improvement to be had by moving to this implementation.

https://github.com/topos-ai/go-s2bits

goos: darwin
goarch: amd64
pkg: github.com/topos-ai/go-s2bits
BenchmarkS2CellIDLevel/30-4             2000000000           1.03 ns/op
BenchmarkS2CellIDLevel/29-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/28-4             2000000000           1.05 ns/op
BenchmarkS2CellIDLevel/27-4             2000000000           1.05 ns/op
BenchmarkS2CellIDLevel/26-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/25-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/24-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/23-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/22-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/21-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/20-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/19-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/18-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/17-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/16-4             2000000000           1.03 ns/op
BenchmarkS2CellIDLevel/15-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/14-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/13-4             2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/12-4             2000000000           1.05 ns/op
BenchmarkS2CellIDLevel/11-4             2000000000           1.03 ns/op
BenchmarkS2CellIDLevel/10-4             2000000000           1.03 ns/op
BenchmarkS2CellIDLevel/9-4              2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/8-4              2000000000           1.05 ns/op
BenchmarkS2CellIDLevel/7-4              2000000000           1.03 ns/op
BenchmarkS2CellIDLevel/6-4              2000000000           1.03 ns/op
BenchmarkS2CellIDLevel/5-4              2000000000           1.04 ns/op
BenchmarkS2CellIDLevel/4-4              2000000000           1.02 ns/op
BenchmarkS2CellIDLevel/3-4              2000000000           1.02 ns/op
BenchmarkS2CellIDLevel/2-4              2000000000           1.03 ns/op
BenchmarkS2CellIDLevel/1-4              2000000000           1.03 ns/op
BenchmarkS2CellIDLevel/0-4              2000000000           1.04 ns/op
BenchmarkCellIDLevel/30-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/29-4               2000000000           0.36 ns/op
BenchmarkCellIDLevel/28-4               2000000000           0.34 ns/op
BenchmarkCellIDLevel/27-4               2000000000           0.34 ns/op
BenchmarkCellIDLevel/26-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/25-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/24-4               2000000000           0.34 ns/op
BenchmarkCellIDLevel/23-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/22-4               2000000000           0.34 ns/op
BenchmarkCellIDLevel/21-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/20-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/19-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/18-4               2000000000           0.34 ns/op
BenchmarkCellIDLevel/17-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/16-4               2000000000           0.34 ns/op
BenchmarkCellIDLevel/15-4               2000000000           0.34 ns/op
BenchmarkCellIDLevel/14-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/13-4               2000000000           0.34 ns/op
BenchmarkCellIDLevel/12-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/11-4               2000000000           0.35 ns/op
BenchmarkCellIDLevel/10-4               2000000000           0.34 ns/op
BenchmarkCellIDLevel/9-4                2000000000           0.35 ns/op
BenchmarkCellIDLevel/8-4                2000000000           0.34 ns/op
BenchmarkCellIDLevel/7-4                2000000000           0.35 ns/op
BenchmarkCellIDLevel/6-4                2000000000           0.34 ns/op
BenchmarkCellIDLevel/5-4                2000000000           0.35 ns/op
BenchmarkCellIDLevel/4-4                2000000000           0.35 ns/op
BenchmarkCellIDLevel/3-4                2000000000           0.34 ns/op
BenchmarkCellIDLevel/2-4                2000000000           0.35 ns/op
BenchmarkCellIDLevel/1-4                2000000000           0.35 ns/op
BenchmarkCellIDLevel/0-4                2000000000           0.35 ns/op
PASS
ok      github.com/topos-ai/go-s2bits   90.225s

Understanding that the maintainers of this library want to continue to support Go 1.8, I'm adding this as an issue that can be referenced in the future.

Thanks!

dsymonds commented 6 years ago

Thanks for the data! This is a compelling reason to use math/bits. It wouldn't be hard to keep the existing version for Go 1.8 and earlier; let me make a change this week to switch to math/bits in a separate file.