mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-27 02:46:47 +01:00
f325410c26
- Return meta-labels for the discovered targets via promutils.Labels instead of map[string]string. This improves the speed of generating meta-labels for discovered targets by up to 5x. - Remove memory allocations in hot paths during ScrapeWork generation. The ScrapeWork contains scrape settings for a single discovered target. This improves the service discovery speed by up to 2x.
21 lines
420 B
Go
21 lines
420 B
Go
package promutils
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func BenchmarkLabelsInternStrings(b *testing.B) {
|
|
b.ReportAllocs()
|
|
b.SetBytes(1)
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
labels := NewLabelsFromMap(map[string]string{
|
|
"job": "node-exporter",
|
|
"instance": "foo.bar.baz:1234",
|
|
"__meta_kubernetes_namespace": "default",
|
|
})
|
|
for pb.Next() {
|
|
labels.InternStrings()
|
|
}
|
|
})
|
|
}
|