pkg/str/str_bench_test.go

36 lines
530 B
Go
Raw Permalink Normal View History

2023-09-18 15:51:20 +08:00
package str
import (
"testing"
)
var s = "1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,."
func BenchmarkB2sFast(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = S2B(s)
}
}
func BenchmarkB2sStd(b *testing.B) {
var _ []byte
for i := 0; i < b.N; i++ {
_ = []byte(s)
}
}
var bt = []byte("1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,.")
func BenchmarkS2BFast(b *testing.B) {
for i := 0; i < b.N; i++ {
_ = B2S(bt)
}
}
func BenchmarkS2BStd(b *testing.B) {
var _ []byte
for i := 0; i < b.N; i++ {
_ = string(bt)
}
}