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

26 lines
357 B
Go

package timer
import "testing"
func BenchmarkFoo1(b *testing.B) {
expensiveSetup()
b.ResetTimer()
for i := 0; i < b.N; i++ {
functionUnderTest()
}
}
func BenchmarkFoo2(b *testing.B) {
for i := 0; i < b.N; i++ {
b.StopTimer()
expensiveSetup()
b.StartTimer()
functionUnderTest()
}
}
func functionUnderTest() {
}
func expensiveSetup() {
}