mirror of
https://github.com/golang/go
synced 2024-09-29 13:24:28 -06:00
regexp: simplify BenchmarkCompileOnepass
One benchmark is fine. Having one per test case is overkill. Change-Id: Id4ce789484dab1e79026bdd23cbcd63b2eaceb3f Reviewed-on: https://go-review.googlesource.com/c/139777 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
689321e108
commit
e2d70b8b4b
@ -227,21 +227,11 @@ func TestRunOnePass(t *testing.T) {
|
||||
}
|
||||
|
||||
func BenchmarkCompileOnepass(b *testing.B) {
|
||||
for _, test := range onePassTests {
|
||||
if test.onePass == notOnePass {
|
||||
continue
|
||||
b.ReportAllocs()
|
||||
const re = `^a.[l-nA-Cg-j]?e$`
|
||||
for i := 0; i < b.N; i++ {
|
||||
if _, err := Compile(re); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
name := test.re
|
||||
if len(name) > 20 {
|
||||
name = name[:20] + "..."
|
||||
}
|
||||
b.Run(name, func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
if _, err := Compile(test.re); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user