Skip to content

Commit 2fe2ba6

Browse files
committed
wip: roundN should be min 1
1 parent 3890eed commit 2fe2ba6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

testing/testing/benchmark.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,12 @@ func (b *B) launch() {
376376
rounds := 100 // TODO: Compute the rounds in a better way
377377
roundN := benchN / int(rounds)
378378

379+
// Ensure roundN is at least 1 to prevent division by zero in BenchmarkResult printing
380+
// when very slow benchmarks can't complete even 1 iteration per round
381+
if roundN < 1 {
382+
roundN = 1
383+
}
384+
379385
for range rounds {
380386
b.runN(int(roundN))
381387
}

0 commit comments

Comments
 (0)