}
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) {
}
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) {