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

Function BenchmarkHSET_Concurrent

hset_benchmark_test.go:213–242  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

211}
212
213func BenchmarkHSET_Concurrent(b *testing.B) {
214 ctx := context.Background()
215
216 // Setup Redis client
217 rdb := redis.NewClient(&redis.Options{
218 Addr: "localhost:6379",
219 DB: 0,
220 PoolSize: 100,
221 })
222 defer rdb.Close()
223
224 // Test connection
225 if err := rdb.Ping(ctx).Err(); err != nil {
226 b.Skipf("Redis server not available: %v", err)
227 }
228
229 // Clean up before and after tests
230 defer func() {
231 rdb.FlushDB(ctx)
232 }()
233
234 // Reduced scales to avoid overwhelming the system with too many concurrent goroutines
235 scales := []int{1, 10, 100, 1000}
236
237 for _, scale := range scales {
238 b.Run(fmt.Sprintf("HSET_%d_operations_concurrent", scale), func(b *testing.B) {
239 benchmarkHSETOperationsConcurrent(b, rdb, ctx, scale)
240 })
241 }
242}
243
244// benchmarkHSETPipelined performs HSET benchmark using pipelining
245func benchmarkHSETPipelined(b *testing.B, rdb *redis.Client, ctx context.Context, operations int) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected