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

Function benchmarkRedisSet

bench_test.go:252–270  ·  view source on GitHub ↗

benchmarkRedisSet runs Set with a []byte value, the closest existing peer of SetFromBuffer for direct comparison.

(b *testing.B, size int)

Source from the content-addressed store, hash-verified

250// benchmarkRedisSet runs Set with a []byte value, the closest existing
251// peer of SetFromBuffer for direct comparison.
252func benchmarkRedisSet(b *testing.B, size int) {
253 ctx := context.Background()
254 client := benchmarkRedisClient(ctx, 10)
255 defer client.Close()
256
257 value := bytes.Repeat([]byte{'x'}, size)
258
259 b.SetBytes(int64(size))
260 b.ReportAllocs()
261 b.ResetTimer()
262
263 b.RunParallel(func(pb *testing.PB) {
264 for pb.Next() {
265 if err := client.Set(ctx, "key", value, 0).Err(); err != nil {
266 b.Fatal(err)
267 }
268 }
269 })
270}
271
272// benchmarkRedisSetFromBuffer is the zero-copy counterpart of benchmarkRedisSet.
273func benchmarkRedisSetFromBuffer(b *testing.B, size int) {

Callers 2

BenchmarkRedisSet_4KiBFunction · 0.85
BenchmarkRedisSet_64KiBFunction · 0.85

Calls 5

benchmarkRedisClientFunction · 0.85
CloseMethod · 0.65
NextMethod · 0.65
ErrMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected