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

Function benchmarkSummaryObserve

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

Source from the content-addressed store, hash-verified

105}
106
107func benchmarkSummaryObserve(w int, b *testing.B) {
108 b.StopTimer()
109
110 wg := new(sync.WaitGroup)
111 wg.Add(w)
112
113 g := new(sync.WaitGroup)
114 g.Add(1)
115
116 s := NewSummary(SummaryOpts{})
117
118 for i := 0; i < w; i++ {
119 go func() {
120 g.Wait()
121
122 for i := 0; i < b.N; i++ {
123 s.Observe(float64(i))
124 }
125
126 wg.Done()
127 }()
128 }
129
130 b.StartTimer()
131 g.Done()
132 wg.Wait()
133}
134
135func BenchmarkSummaryObserve1(b *testing.B) {
136 benchmarkSummaryObserve(1, b)

Callers 4

BenchmarkSummaryObserve1Function · 0.85
BenchmarkSummaryObserve2Function · 0.85
BenchmarkSummaryObserve4Function · 0.85
BenchmarkSummaryObserve8Function · 0.85

Calls 4

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

Tested by

no test coverage detected