diff options
author | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-26 17:57:44 +0200 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2015-11-26 17:57:44 +0200 |
commit | b31fd30964a021e1c719f8b2155bc891bcefb959 (patch) | |
tree | 1fb81446ed1b0861663e93ac3a3cf4e23ef45fec /bytesconv_timing_test.go | |
parent | Eliminated memory allocations from client's DoTimeout and GetTimeout (diff) | |
download | fasthttp-b31fd30964a021e1c719f8b2155bc891bcefb959.tar.gz fasthttp-b31fd30964a021e1c719f8b2155bc891bcefb959.tar.bz2 fasthttp-b31fd30964a021e1c719f8b2155bc891bcefb959.zip |
Added benchmark for comparing unequal strings with EqualBytesStr
Diffstat (limited to 'bytesconv_timing_test.go')
-rw-r--r-- | bytesconv_timing_test.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/bytesconv_timing_test.go b/bytesconv_timing_test.go index a00ba88..387a3f9 100644 --- a/bytesconv_timing_test.go +++ b/bytesconv_timing_test.go @@ -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) { |