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

Function NewHistogram

benchmark/stats/histogram.go:79–103  ·  view source on GitHub ↗

NewHistogram returns a pointer to a new Histogram object that was created with the provided options.

(opts HistogramOptions)

Source from the content-addressed store, hash-verified

77// NewHistogram returns a pointer to a new Histogram object that was created
78// with the provided options.
79func NewHistogram(opts HistogramOptions) *Histogram {
80 if opts.NumBuckets == 0 {
81 opts.NumBuckets = 32
82 }
83 if opts.BaseBucketSize == 0.0 {
84 opts.BaseBucketSize = 1.0
85 }
86 h := Histogram{
87 Buckets: make([]HistogramBucket, opts.NumBuckets),
88 Min: math.MaxInt64,
89 Max: math.MinInt64,
90
91 opts: opts,
92 logBaseBucketSize: math.Log(opts.BaseBucketSize),
93 oneOverLogOnePlusGrowthFactor: 1 / math.Log(1+opts.GrowthFactor),
94 }
95 m := 1.0 + opts.GrowthFactor
96 delta := opts.BaseBucketSize
97 h.Buckets[0].LowBound = float64(opts.MinValue)
98 for i := 1; i < opts.NumBuckets; i++ {
99 h.Buckets[i].LowBound = float64(opts.MinValue) + delta
100 delta = delta * m
101 }
102 return &h
103}
104
105// Print writes textual output of the histogram values.
106func (h *Histogram) Print(w io.Writer) {

Callers 8

mainFunction · 0.92
runWithConnFunction · 0.92
unaryLoopMethod · 0.92
streamingLoopMethod · 0.92
getStatsMethod · 0.92
executeSoakTestInWorkerFunction · 0.92
DoSoakTestFunction · 0.92
computeLatenciesMethod · 0.85

Calls 1

LogMethod · 0.65

Tested by

no test coverage detected