Jochen Voss <
joche...@gmail.com> wrote:
> Now I just want to run one of these sub-benchmarks. I tried -bench
> '^BenchmarkTextLayout/CFFSimple1$' but this runs two of the benchmarks:
>
> > go test -run=^$ -bench '^BenchmarkTextLayout/CFFSimple1$'
> goos: darwin
> goarch: arm64
> pkg:
seehuhn.de/go/pdf/graphics
> BenchmarkTextLayout/CFFSimple1-8 49 24198452 ns/op
> BenchmarkTextLayout/OpenTypeCFFSimple1-8 48 24209569 ns/op
> PASS
> ok
seehuhn.de/go/pdf/graphics 3.804s
>
> How do I just run "BenchmarkTextLayout/CFFSimple1"?
>
The regexp matches against the benchmark name, not the "full name". Slashes are
interpreted as a separator for names to be matched against, thus your regexp
first matches "^BenchmarkTextLayout" against all top-level benchmarks, then
matches "CFFSimple1$" against all sub-benchmarks names found in
"BenchmarkTextLayout" which indeed "CFFSimple1" and "OpenTypeCFFSimple1" are
matches of.
So the following regexp should only match "BenchmarkTextLayout/CFFSimple1".
$ go test -bench='^BenchmarkTextLayout/^CFFSimple1$'
Note the '^' before CFF.
BR.
-w