MCPcopy
hub / github.com/cortexlabs/cortex / BenchmarkBreakerMaybe

Function BenchmarkBreakerMaybe

pkg/proxy/breaker_test.go:399–419  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

397}
398
399func 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
421func BenchmarkBreakerReserve(b *testing.B) {
422 op := func() {}

Callers

nothing calls this directly

Calls 2

MaybeMethod · 0.95
NewBreakerFunction · 0.85

Tested by

no test coverage detected