mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-09-24 11:49:59 +00:00
Add benchmark for tag parsing
Signed-off-by: Clayton O'Neill <claytono@github.com>
This commit is contained in:
parent
4d0cb1992d
commit
9cd711ed3e
1 changed files with 18 additions and 0 deletions
|
@ -527,3 +527,21 @@ func BenchmarkEscapeMetricName(b *testing.B) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkParseDogStatsDTagsToLabels(b *testing.B) {
|
||||||
|
scenarios := map[string]string{
|
||||||
|
"1 tag w/hash": "#test:tag",
|
||||||
|
"1 tag w/o hash": "test:tag",
|
||||||
|
"2 tags, mixed hashes": "tag1:test,#tag2:test",
|
||||||
|
"3 long tags": "tag1:reallylongtagthisisreallylong,tag2:anotherreallylongtag,tag3:thisisyetanotherextraordinarilylongtag",
|
||||||
|
"a-z tags": "a:0,b:1,c:2,d:3,e:4,f:5,g:6,h:7,i:8,j:9,k:0,l:1,m:2,n:3,o:4,p:5,q:6,r:7,s:8,t:9,u:0,v:1,w:2,x:3,y:4,z:5",
|
||||||
|
}
|
||||||
|
|
||||||
|
for name, tags := range scenarios {
|
||||||
|
b.Run(name, func(b *testing.B) {
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
parseDogStatsDTagsToLabels(tags)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue