From 1bac664f4538d9003fdd5579ab91e3bdc02820a5 Mon Sep 17 00:00:00 2001 From: Mikhail Mazurskiy Date: Fri, 8 Mar 2024 09:32:49 +1100 Subject: [PATCH] Add BenchmarkNewSet --- attribute/set_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/attribute/set_test.go b/attribute/set_test.go index 4920f4cbf15..b851d1fc7b0 100644 --- a/attribute/set_test.go +++ b/attribute/set_test.go @@ -356,3 +356,22 @@ func BenchmarkFiltering(b *testing.B) { b.Run("Filtered", benchFn(func(kv attribute.KeyValue) bool { return kv.Key == "A" })) b.Run("AllDropped", benchFn(func(attribute.KeyValue) bool { return false })) } + +var sinkSet attribute.Set + +func BenchmarkNewSet(b *testing.B) { + attrs := []attribute.KeyValue{ + attribute.String("B1", "2"), + attribute.String("C2", "5"), + attribute.String("B3", "2"), + attribute.String("C4", "1"), + attribute.String("A5", "4"), + attribute.String("C6", "3"), + attribute.String("A7", "1"), + } + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + sinkSet = attribute.NewSet(attrs...) + } +}