]> Cypherpunks repositories - gostls13.git/commitdiff
regexp tests: make some benchmarks more meaningful
authorRob Pike <r@golang.org>
Wed, 2 Feb 2011 01:48:42 +0000 (17:48 -0800)
committerRob Pike <r@golang.org>
Wed, 2 Feb 2011 01:48:42 +0000 (17:48 -0800)
The first two "Literal" tests were silly.
Also fix a naming typo in a couple of tests.

R=rsc
CC=golang-dev
https://golang.org/cl/4127045

src/pkg/regexp/all_test.go
src/pkg/regexp/find_test.go

index aed73306454ab9a03b7e8099b44d0ae733080a6b..c7ee4c879707f06a8bdd6a7d43769e6ed5460b6b 100644 (file)
@@ -316,9 +316,9 @@ func TestNumSubexp(t *testing.T) {
 }
 
 func BenchmarkLiteral(b *testing.B) {
-       x := strings.Repeat("x", 50)
+       x := strings.Repeat("x", 50) + "y"
        b.StopTimer()
-       re := MustCompile(x)
+       re := MustCompile("y")
        b.StartTimer()
        for i := 0; i < b.N; i++ {
                if !re.MatchString(x) {
@@ -329,9 +329,9 @@ func BenchmarkLiteral(b *testing.B) {
 }
 
 func BenchmarkNotLiteral(b *testing.B) {
-       x := strings.Repeat("x", 49)
+       x := strings.Repeat("x", 50) + "y"
        b.StopTimer()
-       re := MustCompile("^" + x)
+       re := MustCompile(".y")
        b.StartTimer()
        for i := 0; i < b.N; i++ {
                if !re.MatchString(x) {
index 1690711dd783da837847675c511b9f27c862675c..9909303e92b409ef3eba6bdaf224adabeceaee51 100644 (file)
@@ -381,7 +381,7 @@ func TestFindSubmatchIndex(t *testing.T) {
        }
 }
 
-func TestFindStringSubmatchndex(t *testing.T) {
+func TestFindStringSubmatchIndex(t *testing.T) {
        for _, test := range findTests {
                testFindSubmatchIndex(&test, MustCompile(test.pat).FindStringSubmatchIndex(test.text), t)
        }
@@ -452,7 +452,7 @@ func TestFindAllSubmatchIndex(t *testing.T) {
        }
 }
 
-func TestFindAllStringSubmatchndex(t *testing.T) {
+func TestFindAllStringSubmatchIndex(t *testing.T) {
        for _, test := range findTests {
                testFindAllSubmatchIndex(&test, MustCompile(test.pat).FindAllStringSubmatchIndex(test.text, -1), t)
        }