Skip to content

Commit

Permalink
Add BenchmarkNewSet
Browse files Browse the repository at this point in the history
  • Loading branch information
ash2k committed Mar 7, 2024
1 parent 576965e commit 1bac664
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions attribute/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
}

0 comments on commit 1bac664

Please sign in to comment.