Commit e2d70b8b authored by Russ Cox's avatar Russ Cox

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 689321e1
...@@ -227,21 +227,11 @@ func TestRunOnePass(t *testing.T) { ...@@ -227,21 +227,11 @@ func TestRunOnePass(t *testing.T) {
} }
func BenchmarkCompileOnepass(b *testing.B) { func BenchmarkCompileOnepass(b *testing.B) {
for _, test := range onePassTests {
if test.onePass == notOnePass {
continue
}
name := test.re
if len(name) > 20 {
name = name[:20] + "..."
}
b.Run(name, func(b *testing.B) {
b.ReportAllocs() b.ReportAllocs()
const re = `^a.[l-nA-Cg-j]?e$`
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
if _, err := Compile(test.re); err != nil { if _, err := Compile(re); err != nil {
b.Fatal(err) b.Fatal(err)
} }
} }
})
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment