100-go-mistakes/11-testing/89-benchmark/compiler-optimizations/main_test.go
2021-12-27 15:56:17 +01:00

19 lines
264 B
Go

package main
import "testing"
func BenchmarkPopcnt1(b *testing.B) {
for i := 0; i < b.N; i++ {
popcnt(uint64(i))
}
}
var global uint64
func BenchmarkPopcnt2(b *testing.B) {
var v uint64
for i := 0; i < b.N; i++ {
v = popcnt(uint64(i))
}
global = v
}