1
0
mirror of https://github.com/golang/go synced 2024-11-15 09:20:58 -07:00

runtime: skip most map benchmark combinations by default

Fixes #70008.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-race
Change-Id: I1fd7d1cbda20cc96016c864bcf0696382453e807
Reviewed-on: https://go-review.googlesource.com/c/go/+/623335
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Michael Pratt 2024-10-29 15:32:09 -04:00 committed by Gopher Robot
parent ed035af7b7
commit 0c934b5645

View File

@ -6,6 +6,7 @@ package runtime_test
import ( import (
"encoding/binary" "encoding/binary"
"flag"
"fmt" "fmt"
"math/rand" "math/rand"
"runtime" "runtime"
@ -16,6 +17,8 @@ import (
"unsafe" "unsafe"
) )
var mapbench = flag.Bool("mapbench", false, "enable the full set of map benchmark variants")
const size = 10 const size = 10
func BenchmarkHashStringSpeed(b *testing.B) { func BenchmarkHashStringSpeed(b *testing.B) {
@ -511,9 +514,24 @@ func benchSizes(f func(b *testing.B, n int)) func(*testing.B) {
1 << 22, 1 << 22,
} }
// Cases enabled by default. Set -mapbench for the remainder.
//
// With the other type combinations, there are literally thousands of
// variations. It take too long to run all of these as part of
// builders.
byDefault := map[int]bool{
6: true,
64: true,
1 << 16: true,
}
return func(b *testing.B) { return func(b *testing.B) {
for _, n := range cases { for _, n := range cases {
b.Run("len="+strconv.Itoa(n), func(b *testing.B) { b.Run("len="+strconv.Itoa(n), func(b *testing.B) {
if !*mapbench && !byDefault[n] {
b.Skip("Skipped because -mapbench=false")
}
f(b, n) f(b, n)
}) })
} }