Add benchmark for hashNameAndLabels

Signed-off-by: Clayton O'Neill <claytono@github.com>
This commit is contained in:
Clayton O'Neill 2019-05-16 17:15:38 -04:00
parent a294491e0b
commit 732be39b4b
No known key found for this signature in database
GPG key ID: 5017D45C788B5274

View file

@ -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)
}
})
}
}