Added benchmark for comparing unequal strings with EqualBytesStr

This commit is contained in:
Aliaksandr Valialkin
2015-11-26 17:57:44 +02:00
parent a3fd75d237
commit b31fd30964
+14 -1
View File
@@ -37,7 +37,7 @@ func BenchmarkLowercaseBytesMixed(b *testing.B) {
})
}
func BenchmarkEqualBytesStr(b *testing.B) {
func BenchmarkEqualBytesStrEq(b *testing.B) {
s := "foobarbaraz"
bs := []byte(s)
b.RunParallel(func(pb *testing.PB) {
@@ -49,6 +49,19 @@ func BenchmarkEqualBytesStr(b *testing.B) {
})
}
func BenchmarkEqualBytesStrNe(b *testing.B) {
s := "foobarbaraz"
bs := []byte(s)
bs[len(s)-1] = 'a'
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
if EqualBytesStr(bs, s) {
b.Fatalf("unexpected result: %q = %q", bs, s)
}
}
})
}
func BenchmarkAppendBytesStr(b *testing.B) {
s := "foobarbazbaraz"
b.RunParallel(func(pb *testing.PB) {