BenchmarkPubSubCreation benchmarks PubSub creation and subscription
(b *testing.B)
| 194 | |
| 195 | // BenchmarkPubSubCreation benchmarks PubSub creation and subscription |
| 196 | func 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 |
| 218 | func BenchmarkPubSubPatternCreation(b *testing.B) { |
nothing calls this directly
no test coverage detected