| 325 | } |
| 326 | |
| 327 | func BenchmarkHSETPipelined_RESP2(b *testing.B) { |
| 328 | ctx := context.Background() |
| 329 | |
| 330 | // Setup Redis client |
| 331 | rdb := redis.NewClient(&redis.Options{ |
| 332 | Addr: "localhost:6379", |
| 333 | Password: "", // no password docs |
| 334 | DB: 0, // use default DB |
| 335 | Protocol: 2, |
| 336 | }) |
| 337 | defer rdb.Close() |
| 338 | |
| 339 | // Test connection |
| 340 | if err := rdb.Ping(ctx).Err(); err != nil { |
| 341 | b.Skipf("Redis server not available: %v", err) |
| 342 | } |
| 343 | |
| 344 | // Clean up before and after tests |
| 345 | defer func() { |
| 346 | rdb.FlushDB(ctx) |
| 347 | }() |
| 348 | |
| 349 | scales := []int{1, 10, 100, 1000, 10000, 100000} |
| 350 | |
| 351 | for _, scale := range scales { |
| 352 | b.Run(fmt.Sprintf("HSET_Pipelined_RESP2_%d_operations", scale), func(b *testing.B) { |
| 353 | benchmarkHSETPipelined(b, rdb, ctx, scale) |
| 354 | }) |
| 355 | } |
| 356 | } |