Skip to content

Commit

Permalink
Add benchmark for deep copy
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Gera <[email protected]>
  • Loading branch information
matej-g committed Jul 29, 2022
1 parent d57e26b commit a78cf81
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/store/labelpb/label_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a78cf81

Please sign in to comment.