36 lines
530 B
Go
36 lines
530 B
Go
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)
|
|
}
|
|
}
|