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

Function BenchmarkPoolAndPubSubMixed

pool_pubsub_bench_test.go:322–346  ·  view source on GitHub ↗

============================================================================= COMBINED BENCHMARKS ============================================================================= BenchmarkPoolAndPubSubMixed benchmarks mixed pool stats and PubSub operations

(b *testing.B)

Source from the content-addressed store, hash-verified

320
321// BenchmarkPoolAndPubSubMixed benchmarks mixed pool stats and PubSub operations
322func BenchmarkPoolAndPubSubMixed(b *testing.B) {
323 ctx := context.Background()
324 client := benchmarkClient(32)
325 defer client.Close()
326
327 b.ResetTimer()
328 b.ReportAllocs()
329
330 b.RunParallel(func(pb *testing.PB) {
331 for pb.Next() {
332 // Mix of pool stats collection and PubSub creation
333 if pb.Next() {
334 // Pool stats operation
335 stats := client.PoolStats()
336 _ = stats.Hits + stats.Misses // Use the stats to prevent optimization
337 }
338
339 if pb.Next() {
340 // PubSub operation
341 pubsub := client.Subscribe(ctx, "test-channel")
342 pubsub.Close()
343 }
344 }
345 })
346}
347
348// BenchmarkPoolStatsCollection benchmarks pool statistics collection
349func BenchmarkPoolStatsCollection(b *testing.B) {

Callers

nothing calls this directly

Calls 5

benchmarkClientFunction · 0.85
CloseMethod · 0.65
NextMethod · 0.65
PoolStatsMethod · 0.65
SubscribeMethod · 0.65

Tested by

no test coverage detected