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

Function BenchmarkHSET_RESP2

hset_benchmark_test.go:296–325  ·  view source on GitHub ↗

add same tests but with RESP2

(b *testing.B)

Source from the content-addressed store, hash-verified

294
295// add same tests but with RESP2
296func BenchmarkHSET_RESP2(b *testing.B) {
297 ctx := context.Background()
298
299 // Setup Redis client
300 rdb := redis.NewClient(&redis.Options{
301 Addr: "localhost:6379",
302 Password: "", // no password docs
303 DB: 0, // use default DB
304 Protocol: 2,
305 })
306 defer rdb.Close()
307
308 // Test connection
309 if err := rdb.Ping(ctx).Err(); err != nil {
310 b.Skipf("Redis server not available: %v", err)
311 }
312
313 // Clean up before and after tests
314 defer func() {
315 rdb.FlushDB(ctx)
316 }()
317
318 scales := []int{1, 10, 100, 1000, 10000, 100000}
319
320 for _, scale := range scales {
321 b.Run(fmt.Sprintf("HSET_RESP2_%d_operations", scale), func(b *testing.B) {
322 benchmarkHSETOperations(b, rdb, ctx, scale)
323 })
324 }
325}
326
327func BenchmarkHSETPipelined_RESP2(b *testing.B) {
328 ctx := context.Background()

Callers

nothing calls this directly

Calls 6

benchmarkHSETOperationsFunction · 0.85
CloseMethod · 0.65
ErrMethod · 0.65
PingMethod · 0.65
FlushDBMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected