Add a benchmark for addExtraLabels function

This commit is contained in:
Aliaksandr Valialkin 2022-07-21 18:42:53 +03:00
parent 3515499561
commit 5710165c4b
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1
2 changed files with 21 additions and 1 deletions

View File

@ -26,7 +26,7 @@ bar{foo="bar",a="x"} 2
foo 1 foo 1
# some counter # some counter
# type foobar counter # type foobar counter
foobar{a="b",c="d"} 4`, `x="y"`, `foo{x="y"} 1 foobar{a="b",c="d"} 4`, `x="y"`, `foo{x="y"} 1
# some counter # some counter
# type foobar counter # type foobar counter
foobar{x="y",a="b",c="d"} 4 foobar{x="y",a="b",c="d"} 4

20
push_timing_test.go Normal file
View File

@ -0,0 +1,20 @@
package metrics
import (
"testing"
)
func BenchmarkAddExtraLabels(b *testing.B) {
extraLabels := `foo="bar"`
src := []byte(`foo 1
bar{baz="x"} 2
`)
b.ReportAllocs()
b.SetBytes(1)
b.RunParallel(func(pb *testing.PB) {
var dst []byte
for pb.Next() {
dst = addExtraLabels(dst[:0], src, extraLabels)
}
})
}