[#1619] logger: Add benchmark

```
goos: linux
goarch: amd64
pkg: git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger
cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
1000000000	         0.005202 ns/op	       0 B/op	       0 allocs/op
1000000000	         0.005161 ns/op	       0 B/op	       0 allocs/op
1000000000	         0.005148 ns/op	       0 B/op	       0 allocs/op
1000000000	         0.005130 ns/op	       0 B/op	       0 allocs/op
1000000000	         0.005274 ns/op	       0 B/op	       0 allocs/op
1000000000	         0.005383 ns/op	       0 B/op	       0 allocs/op
1000000000	         0.005285 ns/op	       0 B/op	       0 allocs/op
1000000000	         0.005339 ns/op	       0 B/op	       0 allocs/op
1000000000	         0.005768 ns/op	       0 B/op	       0 allocs/op
1000000000	         0.005606 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger	0.338s
```

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 6fe0682a9e
commit e90c5f6e23

View file

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