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

Function BenchmarkRedisSetGetBytes

bench_test.go:134–158  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

132}
133
134func BenchmarkRedisSetGetBytes(b *testing.B) {
135 ctx := context.Background()
136 client := benchmarkRedisClient(ctx, 10)
137 defer client.Close()
138
139 value := bytes.Repeat([]byte{'1'}, 10000)
140
141 b.ResetTimer()
142
143 b.RunParallel(func(pb *testing.PB) {
144 for pb.Next() {
145 if err := client.Set(ctx, "key", value, 0).Err(); err != nil {
146 b.Fatal(err)
147 }
148
149 got, err := client.Get(ctx, "key").Bytes()
150 if err != nil {
151 b.Fatal(err)
152 }
153 if !bytes.Equal(got, value) {
154 b.Fatalf("got != value")
155 }
156 }
157 })
158}
159
160// benchmarkRedisGet runs the classic Get-into-string path so it can be
161// compared head-to-head with benchmarkRedisGetToBuffer for the same value

Callers

nothing calls this directly

Calls 7

benchmarkRedisClientFunction · 0.85
CloseMethod · 0.65
NextMethod · 0.65
ErrMethod · 0.65
SetMethod · 0.65
GetMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected