Add a benchmark for concurrent counter increments

This commit is contained in:
Stephen McQuay (smcquay) 2018-01-19 15:14:26 -08:00
parent b49b54cdb5
commit b77ed204f6
No known key found for this signature in database
GPG Key ID: 4E4B72F479BA3CE5
1 changed files with 14 additions and 0 deletions

View File

@ -183,3 +183,17 @@ func BenchmarkHistogramNoLabels(b *testing.B) {
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()
}
})
}