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

Function BenchmarkBytesToString

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

Source from the content-addressed store, hash-verified

138}
139
140func BenchmarkBytesToString(b *testing.B) {
141 input := []byte(b.Name())
142
143 b.Run("copy", func(b *testing.B) {
144 b.ReportAllocs()
145
146 for i := 0; i < b.N; i++ {
147 _tmpString = string(input)
148 }
149 })
150
151 b.Run("unsafe", func(b *testing.B) {
152 b.ReportAllocs()
153
154 for i := 0; i < b.N; i++ {
155 _tmpString = BytesToString(input)
156 }
157 })
158}

Callers

nothing calls this directly

Calls 3

BytesToStringFunction · 0.70
NameMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected