From 047fe3ee674a9cefeccc57aea3f843fc8c853d3a Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 16 Nov 2022 23:02:21 +0200 Subject: [PATCH] lib/promscrape: add a benchmark for internLabelStrings() --- lib/promscrape/config_timing_test.go | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/promscrape/config_timing_test.go diff --git a/lib/promscrape/config_timing_test.go b/lib/promscrape/config_timing_test.go new file mode 100644 index 0000000000..293e7f94ed --- /dev/null +++ b/lib/promscrape/config_timing_test.go @@ -0,0 +1,31 @@ +package promscrape + +import ( + "testing" + + "github.com/VictoriaMetrics/VictoriaMetrics/lib/prompbmarshal" +) + +func BenchmarkInternLabelStrings(b *testing.B) { + b.ReportAllocs() + b.SetBytes(1) + b.RunParallel(func(pb *testing.PB) { + labels := []prompbmarshal.Label{ + { + Name: "job", + Value: "node-exporter", + }, + { + Name: "instance", + Value: "foo.bar.baz:1234", + }, + { + Name: "__meta_kubernetes_namespace", + Value: "default", + }, + } + for pb.Next() { + internLabelStrings(labels) + } + }) +}