Created
October 14, 2016 21:53
-
-
Save christineyen/f292f8628cb9dd725caf2bf61ad8e27b to your computer and use it in GitHub Desktop.
er... checking after the fact whether https://github.com/honeycombio/honeytail/commit/1ef49a2de43651954beea92c61b856449d09c4f3 was valid or not.Conclusion:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ go test -bench=. regcmp_test.go | |
testing: warning: no tests to run | |
BenchmarkNegativeMatchBool-8 10000000 118 ns/op | |
BenchmarkNegativeMatchString-8 10000000 128 ns/op | |
BenchmarkPositiveMatchBool-8 1000000 2494 ns/op | |
BenchmarkPositiveMatchString-8 500000 2878 ns/op | |
PASS | |
ok command-line-arguments 6.718s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"regexp" | |
"testing" | |
) | |
var ( | |
reUser = regexp.MustCompile("^# User@Host: (?P<user>[^#]+) @ (?P<host>[^#]+).*$") | |
) | |
const ( | |
negative = "# Query_time: 0.000021 Lock_time: 0.000000 Rows_sent: 494 Rows_examined: 494" | |
positive = "# User@Host: root[root] @ localhost [] Id: 233" | |
) | |
func BenchmarkNegativeMatchBool(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
reUser.MatchString(negative) | |
} | |
} | |
func BenchmarkNegativeMatchString(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
reUser.FindStringSubmatch(negative) | |
} | |
} | |
func BenchmarkPositiveMatchBool(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
reUser.MatchString(positive) | |
} | |
} | |
func BenchmarkPositiveMatchString(b *testing.B) { | |
for n := 0; n < b.N; n++ { | |
reUser.FindStringSubmatch(positive) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment