MCPcopy
hub / github.com/redis/go-redis / BenchmarkStringToBytes

Function BenchmarkStringToBytes

internal/util/unsafe_test.go:120–138  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

118}
119
120func BenchmarkStringToBytes(b *testing.B) {
121 input := b.Name()
122
123 b.Run("copy", func(b *testing.B) {
124 b.ReportAllocs()
125
126 for i := 0; i < b.N; i++ {
127 _tmpBytes = []byte(input)
128 }
129 })
130
131 b.Run("unsafe", func(b *testing.B) {
132 b.ReportAllocs()
133
134 for i := 0; i < b.N; i++ {
135 _tmpBytes = StringToBytes(input)
136 }
137 })
138}
139
140func BenchmarkBytesToString(b *testing.B) {
141 input := []byte(b.Name())

Callers

nothing calls this directly

Calls 3

StringToBytesFunction · 0.70
NameMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected