]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: cut 10 seconds off the race builder's benchmark test
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 14 Sep 2016 18:03:26 +0000 (18:03 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 14 Sep 2016 18:22:16 +0000 (18:22 +0000)
Don't benchmark so many sizes during the race builder's benchmark run.

This package doesn't even use goroutines.

Cuts off 10 seconds.

Updates #17104

Change-Id: Ibb2c7272c18b9014a775949c656a5b930f197cd4
Reviewed-on: https://go-review.googlesource.com/29158
Reviewed-by: David Crawshaw <crawshaw@golang.org>
src/bytes/bytes_test.go

index e9a022b91a989f5a16a5cde24515a76968d41c30..a4c701c8e8f0b58193135260a763b5740b452ec1 100644 (file)
@@ -7,8 +7,10 @@ package bytes_test
 import (
        . "bytes"
        "fmt"
+       "internal/testenv"
        "math/rand"
        "reflect"
+       "strings"
        "testing"
        "unicode"
        "unicode/utf8"
@@ -384,6 +386,9 @@ func valName(x int) string {
 
 func benchBytes(b *testing.B, sizes []int, f func(b *testing.B, n int)) {
        for _, n := range sizes {
+               if isRaceBuilder && n > 4<<10 {
+                       continue
+               }
                b.Run(valName(n), func(b *testing.B) {
                        if len(bmbuf) < n {
                                bmbuf = make([]byte, n)
@@ -396,6 +401,8 @@ func benchBytes(b *testing.B, sizes []int, f func(b *testing.B, n int)) {
 
 var indexSizes = []int{10, 32, 4 << 10, 4 << 20, 64 << 20}
 
+var isRaceBuilder = strings.HasSuffix(testenv.Builder(), "-race")
+
 func BenchmarkIndexByte(b *testing.B) {
        benchBytes(b, indexSizes, bmIndexByte(IndexByte))
 }