From c3e85a732610d072da08ee4a1ec87bfd5b95c506 Mon Sep 17 00:00:00 2001 From: dmathieu Date: Wed, 26 Jun 2024 10:20:51 +0200 Subject: [PATCH] split the set and add attributes benchmarks --- sdk/log/record_test.go | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/sdk/log/record_test.go b/sdk/log/record_test.go index cbbd8942420..e53cf3410d6 100644 --- a/sdk/log/record_test.go +++ b/sdk/log/record_test.go @@ -642,12 +642,24 @@ func TestTruncate(t *testing.T) { func BenchmarkSetAddAttributes(b *testing.B) { kv := log.String("key", "value") - records := make([]Record, b.N) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - records[i].SetAttributes(kv) - records[i].AddAttributes(kv) - } + b.Run("SetAttributes", func(b *testing.B) { + records := make([]Record, b.N) + + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + records[i].SetAttributes(kv) + } + }) + + b.Run("AddAttributes", func(b *testing.B) { + records := make([]Record, b.N) + + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + records[i].AddAttributes(kv) + } + }) }