MCPcopy
hub / github.com/grpc/grpc-go / ChooseRandom

Method ChooseRandom

benchmark/stats/curve.go:156–168  ·  view source on GitHub ↗

ChooseRandom picks a random payload size (in bytes) that follows the underlying weighted random distribution.

()

Source from the content-addressed store, hash-verified

154// ChooseRandom picks a random payload size (in bytes) that follows the
155// underlying weighted random distribution.
156func (pc *PayloadCurve) ChooseRandom() int {
157 target := rand.Float64()
158 var seen float64
159 for _, pcr := range pc.pcrs {
160 seen += pcr.weight
161 if seen >= target {
162 return pcr.chooseRandom()
163 }
164 }
165
166 // This should never happen, but if it does, return a sane default.
167 return 1
168}
169
170// Hash returns a string uniquely identifying a payload curve file for feature
171// matching purposes.

Callers 2

makeFuncUnaryFunction · 0.80
makeFuncStreamFunction · 0.80

Calls 1

chooseRandomMethod · 0.80

Tested by

no test coverage detected