Skip to content

Commit

Permalink
add benchmark retrieving a new logger
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Jun 26, 2024
1 parent 6d45f28 commit d73a901
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sdk/log/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package log // import "go.opentelemetry.io/otel/sdk/log"

import (
"context"
"fmt"
"strconv"
"sync"
"testing"
Expand Down Expand Up @@ -287,3 +288,14 @@ func TestLoggerProviderForceFlush(t *testing.T) {
assert.ErrorIs(t, p.ForceFlush(ctx), assert.AnError, "processor error not returned")
})
}

func BenchmarkLoggerProviderLogger(b *testing.B) {
p := NewLoggerProvider()

b.ResetTimer()
b.ReportAllocs()

for i := 0; i < b.N; i++ {
_ = p.Logger(fmt.Sprintf("%d logger", i))
}
}

0 comments on commit d73a901

Please sign in to comment.