BenchmarkPubSubMultipleChannels benchmarks subscribing to multiple channels
(b *testing.B)
| 272 | |
| 273 | // BenchmarkPubSubMultipleChannels benchmarks subscribing to multiple channels |
| 274 | func BenchmarkPubSubMultipleChannels(b *testing.B) { |
| 275 | ctx := context.Background() |
| 276 | client := benchmarkClient(16) |
| 277 | defer client.Close() |
| 278 | |
| 279 | channelCounts := []int{1, 5, 10, 25, 50, 100} |
| 280 | |
| 281 | for _, channelCount := range channelCounts { |
| 282 | b.Run(fmt.Sprintf("Channels_%d", channelCount), func(b *testing.B) { |
| 283 | // Prepare channel names |
| 284 | channels := make([]string, channelCount) |
| 285 | for i := 0; i < channelCount; i++ { |
| 286 | channels[i] = fmt.Sprintf("channel-%d", i) |
| 287 | } |
| 288 | |
| 289 | b.ResetTimer() |
| 290 | b.ReportAllocs() |
| 291 | |
| 292 | for i := 0; i < b.N; i++ { |
| 293 | pubsub := client.Subscribe(ctx, channels...) |
| 294 | pubsub.Close() |
| 295 | } |
| 296 | }) |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | // BenchmarkPubSubReuse benchmarks reusing PubSub connections |
| 301 | func BenchmarkPubSubReuse(b *testing.B) { |
nothing calls this directly
no test coverage detected