diff options
Diffstat (limited to 'src/pkg/regexp/all_test.go')
| -rw-r--r-- | src/pkg/regexp/all_test.go | 65 | 
1 files changed, 65 insertions, 0 deletions
| diff --git a/src/pkg/regexp/all_test.go b/src/pkg/regexp/all_test.go index e914a7ccb..301a1dfcd 100644 --- a/src/pkg/regexp/all_test.go +++ b/src/pkg/regexp/all_test.go @@ -473,6 +473,11 @@ func TestSplit(t *testing.T) {  	}  } +// This ran out of stack before issue 7608 was fixed. +func TestOnePassCutoff(t *testing.T) { +	MustCompile(`^(?:x{1,1000}){1,1000}$`) +} +  func BenchmarkLiteral(b *testing.B) {  	x := strings.Repeat("x", 50) + "y"  	b.StopTimer() @@ -578,3 +583,63 @@ func BenchmarkAnchoredLongMatch(b *testing.B) {  		re.Match(x)  	}  } + +func BenchmarkOnePassShortA(b *testing.B) { +	b.StopTimer() +	x := []byte("abcddddddeeeededd") +	re := MustCompile("^.bc(d|e)*$") +	b.StartTimer() +	for i := 0; i < b.N; i++ { +		re.Match(x) +	} +} + +func BenchmarkNotOnePassShortA(b *testing.B) { +	b.StopTimer() +	x := []byte("abcddddddeeeededd") +	re := MustCompile(".bc(d|e)*$") +	b.StartTimer() +	for i := 0; i < b.N; i++ { +		re.Match(x) +	} +} + +func BenchmarkOnePassShortB(b *testing.B) { +	b.StopTimer() +	x := []byte("abcddddddeeeededd") +	re := MustCompile("^.bc(?:d|e)*$") +	b.StartTimer() +	for i := 0; i < b.N; i++ { +		re.Match(x) +	} +} + +func BenchmarkNotOnePassShortB(b *testing.B) { +	b.StopTimer() +	x := []byte("abcddddddeeeededd") +	re := MustCompile(".bc(?:d|e)*$") +	b.StartTimer() +	for i := 0; i < b.N; i++ { +		re.Match(x) +	} +} + +func BenchmarkOnePassLongPrefix(b *testing.B) { +	b.StopTimer() +	x := []byte("abcdefghijklmnopqrstuvwxyz") +	re := MustCompile("^abcdefghijklmnopqrstuvwxyz.*$") +	b.StartTimer() +	for i := 0; i < b.N; i++ { +		re.Match(x) +	} +} + +func BenchmarkOnePassLongNotPrefix(b *testing.B) { +	b.StopTimer() +	x := []byte("abcdefghijklmnopqrstuvwxyz") +	re := MustCompile("^.bcdefghijklmnopqrstuvwxyz.*$") +	b.StartTimer() +	for i := 0; i < b.N; i++ { +		re.Match(x) +	} +} | 
