github.com/duomi520/utils@v0.0.0-20240430123446-e03a4cddd6ec/conver_test.go (about) 1 package utils 2 3 import ( 4 "strings" 5 "testing" 6 ) 7 8 var converTestString = strings.Repeat("a", 1024) 9 10 func BenchmarkTestString(b *testing.B) { 11 for i := 0; i < b.N; i++ { 12 b := []byte(converTestString) 13 _ = string(b) 14 } 15 } 16 17 func BenchmarkTestBytesToString(b *testing.B) { 18 for i := 0; i < b.N; i++ { 19 b := StringToBytes(converTestString) 20 _ = BytesToString(b) 21 } 22 }