-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Description
package p
import "testing"
func BenchmarkMapA(b *testing.B) {}
func BenchmarkMapB(b *testing.B) {
b.Run("C", func(b *testing.B) {})
}$ go test -bench="Map/C" x_test.go
goos: darwin
goarch: amd64
BenchmarkMapA-8 2000000000 0.00 ns/op
BenchmarkMapB/C-8 2000000000 0.00 ns/op
PASS
ok command-line-arguments 0.020s
The docs for -bench say:
-bench regexp
Run (sub)benchmarks matching a regular expression.
The given regular expression is split into smaller ones by
top-level '/', where each must match the corresponding part of a
benchmark's identifier.
So I expected only benchmarks matching Map in the first part and C in the second part to match--namely BenchmarkMapB/C. But I got BenchmarkMapA as well.
This arose because I wanted to run only the runtime map sub-benchmarks named "Int64" and the natural command go test -bench="Map/Int64" -run=NONE runtime did not work.
cc @mpvl
Reactions are currently unavailable