Skip to content

Commit 9a7ce41

Browse files
committed
bytes: cut 10 seconds off the race builder's benchmark test
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 <[email protected]>
1 parent f09d045 commit 9a7ce41

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/bytes/bytes_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ package bytes_test
77
import (
88
. "bytes"
99
"fmt"
10+
"internal/testenv"
1011
"math/rand"
1112
"reflect"
13+
"strings"
1214
"testing"
1315
"unicode"
1416
"unicode/utf8"
@@ -384,6 +386,9 @@ func valName(x int) string {
384386

385387
func benchBytes(b *testing.B, sizes []int, f func(b *testing.B, n int)) {
386388
for _, n := range sizes {
389+
if isRaceBuilder && n > 4<<10 {
390+
continue
391+
}
387392
b.Run(valName(n), func(b *testing.B) {
388393
if len(bmbuf) < n {
389394
bmbuf = make([]byte, n)
@@ -396,6 +401,8 @@ func benchBytes(b *testing.B, sizes []int, f func(b *testing.B, n int)) {
396401

397402
var indexSizes = []int{10, 32, 4 << 10, 4 << 20, 64 << 20}
398403

404+
var isRaceBuilder = strings.HasSuffix(testenv.Builder(), "-race")
405+
399406
func BenchmarkIndexByte(b *testing.B) {
400407
benchBytes(b, indexSizes, bmIndexByte(IndexByte))
401408
}

0 commit comments

Comments
 (0)