(w int, b *testing.B)
| 105 | } |
| 106 | |
| 107 | func 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 | |
| 135 | func BenchmarkSummaryObserve1(b *testing.B) { |
| 136 | benchmarkSummaryObserve(1, b) |
no test coverage detected