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

Function BenchmarkPubSubCreation

pool_pubsub_bench_test.go:196–215  ·  view source on GitHub ↗

BenchmarkPubSubCreation benchmarks PubSub creation and subscription

(b *testing.B)

Source from the content-addressed store, hash-verified

194
195// BenchmarkPubSubCreation benchmarks PubSub creation and subscription
196func BenchmarkPubSubCreation(b *testing.B) {
197 ctx := context.Background()
198
199 poolSizes := []int{1, 4, 8, 16, 32}
200
201 for _, poolSize := range poolSizes {
202 b.Run(fmt.Sprintf("PoolSize_%d", poolSize), func(b *testing.B) {
203 client := benchmarkClient(poolSize)
204 defer client.Close()
205
206 b.ResetTimer()
207 b.ReportAllocs()
208
209 for i := 0; i < b.N; i++ {
210 pubsub := client.Subscribe(ctx, "test-channel")
211 pubsub.Close()
212 }
213 })
214 }
215}
216
217// BenchmarkPubSubPatternCreation benchmarks PubSub pattern subscription
218func BenchmarkPubSubPatternCreation(b *testing.B) {

Callers

nothing calls this directly

Calls 4

benchmarkClientFunction · 0.85
CloseMethod · 0.65
SubscribeMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected