mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-11-26 17:21:01 +00:00
Add benchmark for hashNameAndLabels
Signed-off-by: Clayton O'Neill <claytono@github.com>
This commit is contained in:
parent
a294491e0b
commit
732be39b4b
1 changed files with 43 additions and 0 deletions
|
@ -822,3 +822,46 @@ func BenchmarkParseDogStatsDTagsToLabels(b *testing.B) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkHashNameAndLabels(b *testing.B) {
|
||||
scenarios := []struct {
|
||||
name string
|
||||
metric string
|
||||
labels map[string]string
|
||||
}{
|
||||
{
|
||||
name: "no labels",
|
||||
metric: "counter",
|
||||
labels: map[string]string{},
|
||||
}, {
|
||||
name: "one label",
|
||||
metric: "counter",
|
||||
labels: map[string]string{
|
||||
"label": "value",
|
||||
},
|
||||
}, {
|
||||
name: "many labels",
|
||||
metric: "counter",
|
||||
labels: map[string]string{
|
||||
"label0": "value",
|
||||
"label1": "value",
|
||||
"label2": "value",
|
||||
"label3": "value",
|
||||
"label4": "value",
|
||||
"label5": "value",
|
||||
"label6": "value",
|
||||
"label7": "value",
|
||||
"label8": "value",
|
||||
"label9": "value",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
b.Run(s.name, func(b *testing.B) {
|
||||
for n := 0; n < b.N; n++ {
|
||||
hashNameAndLabels(s.metric, s.labels)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue