(w int, b *testing.B)
| 149 | } |
| 150 | |
| 151 | func 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 | |
| 185 | func BenchmarkSummaryWrite1(b *testing.B) { |
| 186 | benchmarkSummaryWrite(1, b) |
no test coverage detected