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

Function benchmarkSummaryWrite

prometheus/summary_test.go:151–183  ·  view source on GitHub ↗
(w int, b *testing.B)

Source from the content-addressed store, hash-verified

149}
150
151func benchmarkSummaryWrite(w int, b *testing.B) {
152 b.StopTimer()
153
154 wg := new(sync.WaitGroup)
155 wg.Add(w)
156
157 g := new(sync.WaitGroup)
158 g.Add(1)
159
160 s := NewSummary(SummaryOpts{})
161
162 for i := 0; i < 1000000; i++ {
163 s.Observe(float64(i))
164 }
165
166 for j := 0; j < w; j++ {
167 outs := make([]dto.Metric, b.N)
168
169 go func(o []dto.Metric) {
170 g.Wait()
171
172 for i := 0; i < b.N; i++ {
173 s.Write(&o[i])
174 }
175
176 wg.Done()
177 }(outs)
178 }
179
180 b.StartTimer()
181 g.Done()
182 wg.Wait()
183}
184
185func BenchmarkSummaryWrite1(b *testing.B) {
186 benchmarkSummaryWrite(1, b)

Callers 4

BenchmarkSummaryWrite1Function · 0.85
BenchmarkSummaryWrite2Function · 0.85
BenchmarkSummaryWrite4Function · 0.85
BenchmarkSummaryWrite8Function · 0.85

Calls 5

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

Tested by

no test coverage detected