]> Cypherpunks.ru repositories - gostls13.git/commitdiff
regexp: simplify BenchmarkCompileOnepass
authorRuss Cox <rsc@golang.org>
Thu, 4 Oct 2018 00:28:47 +0000 (20:28 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 11 Oct 2018 18:01:06 +0000 (18:01 +0000)
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>

src/regexp/onepass_test.go

index b1caa44515035b444f14ef0929e6e2834843830c..6b622ac3564d150afff652fa656f03b47ba85357 100644 (file)
@@ -227,21 +227,11 @@ func TestRunOnePass(t *testing.T) {
 }
 
 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.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)
                }
-               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)
-                               }
-                       }
-               })
        }
 }