@@ -54,7 +54,7 @@ func TestIntMinTableDriven(t *testing.T) {
54
54
}
55
55
56
56
for _ , tt := range tests {
57
- // t.Run enables running "subtests", one for each
57
+ // ` t.Run` enables running "subtests", one for each
58
58
// table entry. These are shown separately
59
59
// when executing `go test -v`.
60
60
testname := fmt .Sprintf ("%d,%d" , tt .a , tt .b )
@@ -68,13 +68,14 @@ func TestIntMinTableDriven(t *testing.T) {
68
68
}
69
69
70
70
// Benchmark tests typically go in `_test.go` files and are
71
- // named beginning with `Benchmark`. The `testing` runner
72
- // executes each benchmark function several times, increasing
73
- // `b.N` on each run until it collects a precise measurement .
71
+ // named beginning with `Benchmark`.
72
+ // Any code that's required for the benchmark to run but should
73
+ // not be measured goes before this loop .
74
74
func BenchmarkIntMin (b * testing.B ) {
75
- // Typically the benchmark runs a function we're
76
- // benchmarking in a loop `b.N` times.
77
- for i := 0 ; i < b .N ; i ++ {
75
+ for b .Loop () {
76
+ // The benchmark runner will automatically execute this loop
77
+ // body many times to determine a reasonable estimate of the
78
+ // run-time of a single iteration.
78
79
IntMin (1 , 2 )
79
80
}
80
81
}
0 commit comments