From f03b8d0968f7a9ba403f5be6079c0c663a4784a1 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 10 Jan 2023 15:41:39 +0000 Subject: [PATCH] Add benchmark copying labels Taken from previous tsdb/test/BenchmarkLabelsClone. Signed-off-by: Bryan Boreham --- model/labels/labels_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/model/labels/labels_test.go b/model/labels/labels_test.go index 69beb2fc3e..1902f2f71d 100644 --- a/model/labels/labels_test.go +++ b/model/labels/labels_test.go @@ -696,6 +696,25 @@ func BenchmarkLabels_Hash(b *testing.B) { } } +func BenchmarkLabels_Copy(b *testing.B) { + m := map[string]string{ + "job": "node", + "instance": "123.123.1.211:9090", + "path": "/api/v1/namespaces//deployments/", + "method": "GET", + "namespace": "system", + "status": "500", + "prometheus": "prometheus-core-1", + "datacenter": "eu-west-1", + "pod_name": "abcdef-99999-defee", + } + l := FromMap(m) + + for i := 0; i < b.N; i++ { + l = l.Copy() + } +} + func TestMarshaling(t *testing.T) { lbls := FromStrings("aaa", "111", "bbb", "2222", "ccc", "33333") expectedJSON := "{\"aaa\":\"111\",\"bbb\":\"2222\",\"ccc\":\"33333\"}"