Skip to content

Commit

Permalink
Add BenchmarkLoggerEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Aug 7, 2024
1 parent 92418c2 commit 21faca0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions sdk/log/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,24 @@ func TestLoggerEnabled(t *testing.T) {
})
}
}

func BenchmarkLoggerEnabled(b *testing.B) {
provider := NewLoggerProvider(
WithProcessor(newFilterProcessor("0", false)),
WithProcessor(newFilterProcessor("1", true)),
)
logger := provider.Logger("BenchmarkLoggerEnabled")
ctx, r := context.Background(), log.Record{}
r.SetSeverityText("test")

var enabled bool

b.ReportAllocs()
b.ResetTimer()

for n := 0; n < b.N; n++ {
enabled = logger.Enabled(ctx, r)
}

_ = enabled
}

0 comments on commit 21faca0

Please sign in to comment.