diff options
Diffstat (limited to 'src/pkg/testing/regexp_test.go')
-rw-r--r-- | src/pkg/testing/regexp_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/pkg/testing/regexp_test.go b/src/pkg/testing/regexp_test.go index 8f6b20c67..66139ea1e 100644 --- a/src/pkg/testing/regexp_test.go +++ b/src/pkg/testing/regexp_test.go @@ -279,3 +279,33 @@ func TestMatchFunction(t *T) { matchFunctionTest(t, test.re, test.text, test.match); } } + +func BenchmarkSimpleMatch(b *B) { + b.StopTimer(); + re, _ := CompileRegexp("a"); + b.StartTimer(); + + for i := 0; i < b.N; i++ { + re.MatchString("a") + } +} + +func BenchmarkUngroupedMatch(b *B) { + b.StopTimer(); + re, _ := CompileRegexp("[a-z]+ [0-9]+ [a-z]+"); + b.StartTimer(); + + for i := 0; i < b.N; i++ { + re.MatchString("word 123 other") + } +} + +func BenchmarkGroupedMatch(b *B) { + b.StopTimer(); + re, _ := CompileRegexp("([a-z]+) ([0-9]+) ([a-z]+)"); + b.StartTimer(); + + for i := 0; i < b.N; i++ { + re.MatchString("word 123 other") + } +} |