From a78cf81627947e1a9cde40dc7dac4f446f9f49cf Mon Sep 17 00:00:00 2001 From: Matej Gera Date: Fri, 29 Jul 2022 14:36:51 +0200 Subject: [PATCH] Add benchmark for deep copy Signed-off-by: Matej Gera --- pkg/store/labelpb/label_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/store/labelpb/label_test.go b/pkg/store/labelpb/label_test.go index bf57b801ef..768c49f907 100644 --- a/pkg/store/labelpb/label_test.go +++ b/pkg/store/labelpb/label_test.go @@ -209,6 +209,18 @@ func BenchmarkTransformWithAndWithoutCopy(b *testing.B) { ret = ZLabelsToPromLabels(lbls) } }) + b.Run("ZLabelsToPromLabelsWithDeepCopy", func(b *testing.B) { + b.ReportAllocs() + lbls := make([]ZLabel, num) + for i := 0; i < num; i++ { + lbls[i] = ZLabel{Name: fmt.Sprintf(fmtLbl, i), Value: fmt.Sprintf(fmtLbl, i)} + } + b.ResetTimer() + + for i := 0; i < b.N; i++ { + ret = ZLabelsToPromLabels(DeepCopy(lbls)) + } + }) } func TestSortZLabelSets(t *testing.T) {