Skip to content

Commit 498b361

Browse files
committed
fixup: allow bench with round count (easier testable)
1 parent 09c7fbe commit 498b361

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

testing/testing/benchmark.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ func (b *B) runN(n int) {
227227
b.previousN = n
228228
b.previousDuration = b.duration
229229

230+
b.codspeedItersPerRound = append(b.codspeedItersPerRound, int64(n))
231+
230232
if b.loop.n > 0 && !b.loop.done && !b.failed {
231233
b.Error("benchmark function returned without B.Loop() == false (break or return in loop?)")
232234
}
@@ -280,7 +282,8 @@ var labelsOnce sync.Once
280282
// subbenchmarks. b must not have subbenchmarks.
281283
func (b *B) run() {
282284
labelsOnce.Do(func() {
283-
fmt.Fprintf(b.w, "Running with codspeed instrumentation\n")
285+
fmt.Fprintf(b.w, "Running with CodSpeed instrumentation\n")
286+
284287
fmt.Fprintf(b.w, "goos: %s\n", runtime.GOOS)
285288
fmt.Fprintf(b.w, "goarch: %s\n", runtime.GOARCH)
286289
if b.importPath != "" {
@@ -375,7 +378,6 @@ func (b *B) launch() {
375378

376379
for range rounds {
377380
b.runN(int(roundN))
378-
b.codspeedItersPerRound = append(b.codspeedItersPerRound, int64(roundN))
379381
}
380382
}
381383
}

0 commit comments

Comments
 (0)