Add a benchmark for concurrent counter increments
This commit is contained in:
parent
b49b54cdb5
commit
b77ed204f6
|
@ -183,3 +183,17 @@ func BenchmarkHistogramNoLabels(b *testing.B) {
|
||||||
m.Observe(3.1415)
|
m.Observe(3.1415)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkParallelCounter(b *testing.B) {
|
||||||
|
c := NewCounter(CounterOpts{
|
||||||
|
Name: "benchmark_counter",
|
||||||
|
Help: "A Counter to benchmark it.",
|
||||||
|
})
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
|
for pb.Next() {
|
||||||
|
c.Inc()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue