Skip to content

Commit 20e1913

Browse files
committed
fix: only show runparalllel warning once to avoid spamming the console
1 parent ec303fc commit 20e1913

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

testing/testing/benchmark.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ var (
3939
benchmarkMemory *bool
4040

4141
benchTime = durationOrCountFlag{d: 1 * time.Second} // changed during test of testing package
42+
43+
runParallelWarningOnce sync.Once
4244
)
4345

4446
type durationOrCountFlag struct {
@@ -1177,11 +1179,12 @@ func (pb *PB) Next() bool {
11771179
// RunParallel reports ns/op values as wall time for the benchmark as a whole,
11781180
// not the sum of wall time or CPU time over each parallel goroutine.
11791181
func (b *B) RunParallel(body func(*PB)) {
1180-
fmt.Println("RunParallel is currently unsupported when running with CodSpeed. Continuing without measurements...")
1181-
11821182
if b.N == 0 {
11831183
return // Nothing to do when probing.
11841184
}
1185+
runParallelWarningOnce.Do(func() {
1186+
fmt.Println("WARNING: RunParallel is currently unsupported when running with CodSpeed. Continuing without measurements...")
1187+
})
11851188
// Calculate grain size as number of iterations that take ~100µs.
11861189
// 100µs is enough to amortize the overhead and provide sufficient
11871190
// dynamic load balancing.

0 commit comments

Comments
 (0)