MCPcopy
hub / github.com/prometheus/client_golang / benchmarkHistogramWrite

Function benchmarkHistogramWrite

prometheus/histogram_test.go:79–111  ·  prometheus/histogram_test.go::benchmarkHistogramWrite
(w int, b *testing.B)

Source from the content-addressed store, hash-verified

77}
78
79func benchmarkHistogramWrite(w int, b *testing.B) {
80 b.StopTimer()
81
82 wg := new(sync.WaitGroup)
83 wg.Add(w)
84
85 g := new(sync.WaitGroup)
86 g.Add(1)
87
88 s := NewHistogram(HistogramOpts{})
89
90 for i := 0; i < 1000000; i++ {
91 s.Observe(float64(i))
92 }
93
94 for j := 0; j < w; j++ {
95 outs := make([]dto.Metric, b.N)
96
97 go func(o []dto.Metric) {
98 g.Wait()
99
100 for i := 0; i < b.N; i++ {
101 s.Write(&o[i])
102 }
103
104 wg.Done()
105 }(outs)
106 }
107
108 b.StartTimer()
109 g.Done()
110 wg.Wait()
111}
112
113func BenchmarkHistogramWrite1(b *testing.B) {
114 benchmarkHistogramWrite(1, b)

Callers 4

BenchmarkHistogramWrite1Function · 0.85
BenchmarkHistogramWrite2Function · 0.85
BenchmarkHistogramWrite4Function · 0.85
BenchmarkHistogramWrite8Function · 0.85

Calls 5

ObserveMethod · 0.95
WaitMethod · 0.80
NewHistogramFunction · 0.70
AddMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected