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

Function BenchmarkHSETPipelined

hset_benchmark_test.go:184–211  ·  view source on GitHub ↗

BenchmarkHSETPipelined benchmarks HSET operations using pipelining for better performance

(b *testing.B)

Source from the content-addressed store, hash-verified

182
183// BenchmarkHSETPipelined benchmarks HSET operations using pipelining for better performance
184func BenchmarkHSETPipelined(b *testing.B) {
185 ctx := context.Background()
186
187 // Setup Redis client
188 rdb := redis.NewClient(&redis.Options{
189 Addr: "localhost:6379",
190 DB: 0,
191 })
192 defer rdb.Close()
193
194 // Test connection
195 if err := rdb.Ping(ctx).Err(); err != nil {
196 b.Skipf("Redis server not available: %v", err)
197 }
198
199 // Clean up before and after tests
200 defer func() {
201 rdb.FlushDB(ctx)
202 }()
203
204 scales := []int{1, 10, 100, 1000, 10000, 100000}
205
206 for _, scale := range scales {
207 b.Run(fmt.Sprintf("HSET_Pipelined_%d_operations", scale), func(b *testing.B) {
208 benchmarkHSETPipelined(b, rdb, ctx, scale)
209 })
210 }
211}
212
213func BenchmarkHSET_Concurrent(b *testing.B) {
214 ctx := context.Background()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected