MCPcopy
hub / github.com/dgraph-io/dgraph / BenchmarkRateLimiter

Function BenchmarkRateLimiter

worker/proposal_test.go:108–136  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

106}
107
108func 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}

Callers

nothing calls this directly

Calls 4

bleedMethod · 0.95
proposeAndWaitEmulatorFunction · 0.85
RunMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected