mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
regexp tests: make some benchmarks more meaningful
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
This commit is contained in:
parent
97ce34244f
commit
8a2d706487
2 changed files with 6 additions and 6 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue