aboutsummaryrefslogtreecommitdiff
path: root/src/testing/benchmark.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/benchmark.go')
-rw-r--r--src/testing/benchmark.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/testing/benchmark.go b/src/testing/benchmark.go
index a856312f8f..be9b87f80b 100644
--- a/src/testing/benchmark.go
+++ b/src/testing/benchmark.go
@@ -7,6 +7,7 @@ package testing
import (
"flag"
"fmt"
+ "internal/race"
"internal/sysinfo"
"io"
"math"
@@ -184,6 +185,7 @@ func (b *B) runN(n int) {
// Try to get a comparable environment for each run
// by clearing garbage from previous runs.
runtime.GC()
+ b.raceErrors = -race.Errors()
b.N = n
b.parallelism = 1
b.ResetTimer()
@@ -192,7 +194,8 @@ func (b *B) runN(n int) {
b.StopTimer()
b.previousN = n
b.previousDuration = b.duration
- if fetchRaceErrors() > 0 {
+ b.raceErrors += race.Errors()
+ if b.raceErrors > 0 {
b.Errorf("race detected during execution of benchmark")
}
}