Merge pull request #368 from smcquay/bench/counter

Add a benchmark for concurrent counter increments
This commit is contained in:
Björn Rabenstein 2018-01-20 15:10:31 +01:00 committed by GitHub
commit 06bc6e01f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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()
}
})
}