[#1619] logger: Add benchmark

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2025-02-04 09:11:36 +03:00
parent da314a47b4
commit 5e0223c20d
2 changed files with 45 additions and 0 deletions

View file

@ -0,0 +1,28 @@
package logger
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func BenchmarkLogger(b *testing.B) {
ctx := context.Background()
prm := Prm{}
require.NoError(b, prm.SetLevelString("debug"))
logger, err := NewLogger(prm)
require.NoError(b, err)
b.ResetTimer()
b.ReportAllocs()
for range b.N {
logger.Debug(ctx, "test debug")
logger.Info(ctx, "test info")
logger.Warn(ctx, "test warn")
logger.Error(ctx, "test error")
}
}