1
0
mirror of https://github.com/golang/go synced 2024-11-11 22:50:22 -07:00

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 <crawshaw@golang.org>
This commit is contained in:
Brad Fitzpatrick 2016-09-14 18:03:26 +00:00
parent f09d0458d3
commit 9a7ce41d6c

View 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))
}