Skip to content

Commit

Permalink
Add Benchmarks for escapeMetricName
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Akins <[email protected]>
  • Loading branch information
bakins committed Apr 9, 2019
1 parent e6bdf13 commit 7f70979
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
}

0 comments on commit 7f70979

Please sign in to comment.