(b *testing.B)
| 397 | } |
| 398 | |
| 399 | func BenchmarkBreakerMaybe(b *testing.B) { |
| 400 | op := func() {} |
| 401 | |
| 402 | for _, c := range []int{1, 10, 100, 1000} { |
| 403 | breaker := NewBreaker(BreakerParams{QueueDepth: 10000000, MaxConcurrency: c, InitialCapacity: c}) |
| 404 | |
| 405 | b.Run(fmt.Sprintf("%d-sequential", c), func(b *testing.B) { |
| 406 | for j := 0; j < b.N; j++ { |
| 407 | breaker.Maybe(context.Background(), op) |
| 408 | } |
| 409 | }) |
| 410 | |
| 411 | b.Run(fmt.Sprintf("%d-parallel", c), func(b *testing.B) { |
| 412 | b.RunParallel(func(pb *testing.PB) { |
| 413 | for pb.Next() { |
| 414 | breaker.Maybe(context.Background(), op) |
| 415 | } |
| 416 | }) |
| 417 | }) |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | func BenchmarkBreakerReserve(b *testing.B) { |
| 422 | op := func() {} |
nothing calls this directly
no test coverage detected