Skip to content

Commit

Permalink
regexp: don't run slow benchmarks on race builders
Browse files Browse the repository at this point in the history
Shave 6.5 minutes off the *-race build time.

The *-race builders run:

    go test -short -race -run=^$ -benchtime=.1s -cpu=4 $PKG

... for each package with benchmarks.

The point isn't to measure the speed of the packages, but rather to
see if there are any races. (which is why a benchtime of 0.1 seconds
is used)

But running in race mode makes things slower and our benchmarks aren't
all very fast to begin with.

The regexp benchmarks in race were taking over 6.5 minutes. With this
CL, it's now 8 seconds.

Updates #17104

Change-Id: I054528d09b1568d37aac9f9b515d6ed90a5cf5b0
Reviewed-on: https://go-review.googlesource.com/29156
Run-TryBot: Brad Fitzpatrick <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: David Crawshaw <[email protected]>
  • Loading branch information
bradfitz committed Sep 14, 2016
1 parent 167e381 commit f09d045
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/regexp/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bufio"
"compress/bzip2"
"fmt"
"internal/testenv"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -659,9 +660,14 @@ func makeText(n int) []byte {
}

func BenchmarkMatch(b *testing.B) {
isRaceBuilder := strings.HasSuffix(testenv.Builder(), "-race")

for _, data := range benchData {
r := MustCompile(data.re)
for _, size := range benchSizes {
if isRaceBuilder && size.n > 1<<10 {
continue
}
t := makeText(size.n)
b.Run(data.name+"/"+size.name, func(b *testing.B) {
b.SetBytes(int64(size.n))
Expand Down

0 comments on commit f09d045

Please sign in to comment.