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

Function benchmarkHistogramObserve

prometheus/histogram_test.go:35–61  ·  view source on GitHub ↗
(w int, b *testing.B)

Source from the content-addressed store, hash-verified

33)
34
35func benchmarkHistogramObserve(w int, b *testing.B) {
36 b.StopTimer()
37
38 wg := new(sync.WaitGroup)
39 wg.Add(w)
40
41 g := new(sync.WaitGroup)
42 g.Add(1)
43
44 s := NewHistogram(HistogramOpts{})
45
46 for i := 0; i < w; i++ {
47 go func() {
48 g.Wait()
49
50 for i := 0; i < b.N; i++ {
51 s.Observe(float64(i))
52 }
53
54 wg.Done()
55 }()
56 }
57
58 b.StartTimer()
59 g.Done()
60 wg.Wait()
61}
62
63func BenchmarkHistogramObserve1(b *testing.B) {
64 benchmarkHistogramObserve(1, b)

Callers 4

Calls 4

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

Tested by

no test coverage detected