github.com/glycerine/zebrapack@v4.1.1-0.20181107023619-e955d028f9bf+incompatible/slides/state-of-go/runtime/mutex/main_test.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func benchFunc(b *testing.B, f func(int) map[int]int) { 9 for n := 10; n <= 10000; n *= 10 { 10 b.Run(fmt.Sprint(n), func(b *testing.B) { 11 for i := 0; i < b.N; i++ { 12 f(n) 13 } 14 }) 15 } 16 } 17 18 func BenchmarkNarrowSection(b *testing.B) { benchFunc(b, countFactorsNarrowSection) } 19 func BenchmarkWideSection(b *testing.B) { benchFunc(b, countFactorsWideSection) } 20 func BenchmarkSq(b *testing.B) { benchFunc(b, countFactorsSeq) }