2023-05-13 00:55:47 +08:00
|
|
|
package str
|
2023-02-03 16:18:31 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|