func BenchmarkPopcountLoop(b *testing.B) { var x uint64 x = 0 for i := 0; i < b.N; i++ { _ = popcountLoop.PopCount(x) } }
func main() { fmt.Println(popcount.PopCount(4)) fmt.Println(popcountLoop.PopCount(4)) fmt.Println(popcountClearLsb.PopCount(4)) fmt.Println(popcountShift64.PopCount(4)) br := testing.Benchmark(BenchmarkPopcount) fmt.Println(br) br = testing.Benchmark(BenchmarkPopcountLoop) fmt.Println(br) br = testing.Benchmark(BenchmarkPopcountShift64) fmt.Println(br) br = testing.Benchmark(BenchmarkPopcountClearLsb) fmt.Println(br) }