2023-12-02 18:58:20 +02:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2024-02-29 08:05:28 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2023-12-02 18:58:20 +02:00
|
|
|
|
|
|
|
package trace
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func BenchmarkTraceStateParse(b *testing.B) {
|
|
|
|
for _, test := range testcases {
|
|
|
|
b.Run(test.name, func(b *testing.B) {
|
|
|
|
b.ResetTimer()
|
|
|
|
b.ReportAllocs()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, _ = ParseTraceState(test.in)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkTraceStateString(b *testing.B) {
|
|
|
|
for _, test := range testcases {
|
|
|
|
if len(test.tracestate.list) == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
b.Run(test.name, func(b *testing.B) {
|
|
|
|
b.ResetTimer()
|
|
|
|
b.ReportAllocs()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_ = test.tracestate.String()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkTraceStateInsert(b *testing.B) {
|
|
|
|
for _, test := range insertTestcase {
|
|
|
|
b.Run(test.name, func(b *testing.B) {
|
|
|
|
b.ResetTimer()
|
|
|
|
b.ReportAllocs()
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
_, _ = test.tracestate.Insert(test.key, test.value)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|