Add Benchmarks for escapeMetricName

Signed-off-by: Brian Akins <brian@akins.org>
This commit is contained in:
Brian Akins 2019-04-09 11:56:58 -04:00
parent e6bdf13407
commit 7f70979120

View file

@ -413,3 +413,24 @@ func getTelemetryCounterValue(counter prometheus.Counter) float64 {
}
return metric.Counter.GetValue()
}
func BenchmarkEscapeMetricName(b *testing.B) {
scenarios := []string{
"clean",
"0starts_with_digit",
"with_underscore",
"with.dot",
"with😱emoji",
"with.*.multiple",
"test.web-server.foo.bar",
"",
}
for _, s := range scenarios {
b.Run(s, func(b *testing.B) {
for n := 0; n < b.N; n++ {
escapeMetricName(s)
}
})
}
}