Skip to content

Commit

Permalink
Add benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed Jun 27, 2024
1 parent 4a19735 commit fcb8d0c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions processors/minsev/minsev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,27 @@ func TestLogProcessorNilDownstream(t *testing.T) {
assert.NoError(t, p.Shutdown(ctx))
})
}

func BenchmarkLogProcessor(b *testing.B) {
rPtr := new(log.Record)
rPtr.SetSeverity(api.SeverityTrace)
ctx, r := context.Background(), *rPtr

run := func(p log.Processor) func(b *testing.B) {
return func(b *testing.B) {
var err error
var enabled bool
b.ReportAllocs()
for n := 0; n < b.N; n++ {
enabled = p.Enabled(ctx, r)
err = p.OnEmit(ctx, r)
}

_, _ = err, enabled
}
}

b.Run("Base", run(defaultProcessor))
b.Run("Enabled", run(NewLogProcessor(nil, api.SeverityTrace)))
b.Run("Disabled", run(NewLogProcessor(nil, api.SeverityDebug)))
}

0 comments on commit fcb8d0c

Please sign in to comment.