diff --git a/prometheus/benchmark_test.go b/prometheus/benchmark_test.go index 6ae7333..a3d8669 100644 --- a/prometheus/benchmark_test.go +++ b/prometheus/benchmark_test.go @@ -14,6 +14,7 @@ package prometheus import ( + "sync" "testing" ) @@ -32,6 +33,29 @@ func BenchmarkCounterWithLabelValues(b *testing.B) { } } +func BenchmarkCounterWithLabelValuesConcurrent(b *testing.B) { + m := NewCounterVec( + CounterOpts{ + Name: "benchmark_counter", + Help: "A counter to benchmark it.", + }, + []string{"one", "two", "three"}, + ) + b.ReportAllocs() + b.ResetTimer() + wg := sync.WaitGroup{} + for i := 0; i < 10; i++ { + wg.Add(1) + go func() { + for j := 0; j < b.N/10; j++ { + m.WithLabelValues("eins", "zwei", "drei").Inc() + } + wg.Done() + }() + } + wg.Wait() +} + func BenchmarkCounterWithMappedLabels(b *testing.B) { m := NewCounterVec( CounterOpts{