benchmarkRedisSet runs Set with a []byte value, the closest existing peer of SetFromBuffer for direct comparison.
(b *testing.B, size int)
| 250 | // benchmarkRedisSet runs Set with a []byte value, the closest existing |
| 251 | // peer of SetFromBuffer for direct comparison. |
| 252 | func 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. |
| 273 | func benchmarkRedisSetFromBuffer(b *testing.B, size int) { |
no test coverage detected