ctx.sh/apex@v0.2.1/benchmark_test.go (about) 1 package apex 2 3 import ( 4 "testing" 5 6 "github.com/prometheus/client_golang/prometheus" 7 ) 8 9 func BenchmarkMain(b *testing.B) { 10 registry := prometheus.NewPedanticRegistry() 11 12 metrics := New(MetricsOpts{ 13 Separator: '_', 14 Registry: registry, 15 PanicOnError: true, 16 }).WithPrefix("apex", "example").WithLabels("role") 17 18 for i := 0; i < 1000000; i++ { 19 metrics.CounterInc("foo", "example") 20 } 21 22 for i := 0; i < 1000000; i++ { 23 metrics.CounterAdd("foo", 5.0, "example") 24 } 25 }