mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-30 04:40:41 +02:00
Split the set and add attributes benchmarks (#5546)
This benchmark currently tests two rather different methods within the same loop, which makes it hard to see what could be causing a performance degradation. Related: #5054. ``` BenchmarkSetAddAttributes/SetAttributes-10 14066331 82.80 ns/op 48 B/op 1 allocs/op BenchmarkSetAddAttributes/AddAttributes-10 19333711 114.7 ns/op 0 B/op 0 allocs/op ```
This commit is contained in:
parent
cda5094cdd
commit
649484ef38
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user