mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
51 lines
952 B
Go
51 lines
952 B
Go
package fasthttp
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func BenchmarkLowercaseBytesNoop(b *testing.B) {
|
|
src := []byte("foobarbaz_lowercased_all")
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
s := make([]byte, len(src))
|
|
for pb.Next() {
|
|
copy(s, src)
|
|
lowercaseBytes(s)
|
|
}
|
|
})
|
|
}
|
|
|
|
func BenchmarkLowercaseBytesAll(b *testing.B) {
|
|
src := []byte("FOOBARBAZ_UPPERCASED_ALL")
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
s := make([]byte, len(src))
|
|
for pb.Next() {
|
|
copy(s, src)
|
|
lowercaseBytes(s)
|
|
}
|
|
})
|
|
}
|
|
|
|
func BenchmarkLowercaseBytesMixed(b *testing.B) {
|
|
src := []byte("Foobarbaz_Uppercased_Mix")
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
s := make([]byte, len(src))
|
|
for pb.Next() {
|
|
copy(s, src)
|
|
lowercaseBytes(s)
|
|
}
|
|
})
|
|
}
|
|
|
|
func BenchmarkEqualBytesStr(b *testing.B) {
|
|
s := "foobarbaraz"
|
|
bs := []byte(s)
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
for pb.Next() {
|
|
if !EqualBytesStr(bs, s) {
|
|
b.Fatalf("unexpected result: %q != %q", bs, s)
|
|
}
|
|
}
|
|
})
|
|
}
|