(b *testing.B)
| 106 | } |
| 107 | |
| 108 | func BenchmarkRateLimiter(b *testing.B) { |
| 109 | ious := []int{256} |
| 110 | retries := []int{3} |
| 111 | var failed, success uint64 |
| 112 | |
| 113 | for _, iou := range ious { |
| 114 | for _, retry := range retries { |
| 115 | b.Run(fmt.Sprintf("IOU:%d-Retry:%d", iou, retry), func(b *testing.B) { |
| 116 | l := &rateLimiter{c: sync.NewCond(&sync.Mutex{}), max: iou} |
| 117 | go l.bleed() |
| 118 | |
| 119 | // var success, failed uint64 |
| 120 | b.RunParallel(func(pb *testing.PB) { |
| 121 | r := rand.New(rand.NewSource(time.Now().UnixNano())) |
| 122 | for pb.Next() { |
| 123 | if err := proposeAndWaitEmulator(l, r, retry, false); err != nil { |
| 124 | atomic.AddUint64(&failed, 1) |
| 125 | } else { |
| 126 | atomic.AddUint64(&success, 1) |
| 127 | } |
| 128 | } |
| 129 | }) |
| 130 | |
| 131 | fmt.Println("IOU:", iou, "Max Retries:", retry, "Success:", |
| 132 | success, "Failed:", failed) |
| 133 | }) |
| 134 | } |
| 135 | } |
| 136 | } |
nothing calls this directly
no test coverage detected