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

Function benchmarkRedisSetFromBuffer

bench_test.go:273–291  ·  view source on GitHub ↗

benchmarkRedisSetFromBuffer is the zero-copy counterpart of benchmarkRedisSet.

(b *testing.B, size int)

Source from the content-addressed store, hash-verified

271
272// benchmarkRedisSetFromBuffer is the zero-copy counterpart of benchmarkRedisSet.
273func benchmarkRedisSetFromBuffer(b *testing.B, size int) {
274 ctx := context.Background()
275 client := benchmarkRedisClient(ctx, 10)
276 defer client.Close()
277
278 value := bytes.Repeat([]byte{'x'}, size)
279
280 b.SetBytes(int64(size))
281 b.ReportAllocs()
282 b.ResetTimer()
283
284 b.RunParallel(func(pb *testing.PB) {
285 for pb.Next() {
286 if err := client.SetFromBuffer(ctx, "key", value).Err(); err != nil {
287 b.Fatal(err)
288 }
289 }
290 })
291}
292
293// benchmarkRedisGetRawSocket bypasses go-redis entirely. It opens a raw TCP
294// connection per goroutine, sends GET key directly, and reads the bulk-string

Calls 5

benchmarkRedisClientFunction · 0.85
CloseMethod · 0.65
NextMethod · 0.65
ErrMethod · 0.65
SetFromBufferMethod · 0.65

Tested by

no test coverage detected