benchmarkRedisSetFromBuffer is the zero-copy counterpart of benchmarkRedisSet.
(b *testing.B, size int)
| 271 | |
| 272 | // benchmarkRedisSetFromBuffer is the zero-copy counterpart of benchmarkRedisSet. |
| 273 | func 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 |
no test coverage detected