add same tests but with RESP2
(b *testing.B)
| 294 | |
| 295 | // add same tests but with RESP2 |
| 296 | func 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 | |
| 327 | func BenchmarkHSETPipelined_RESP2(b *testing.B) { |
| 328 | ctx := context.Background() |