[#1619] logger: Add benchmark
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
da314a47b4
commit
5e0223c20d
2 changed files with 45 additions and 0 deletions
28
pkg/util/logger/logger_test.go
Normal file
28
pkg/util/logger/logger_test.go
Normal 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")
|
||||
}
|
||||
}
|
17
pkg/util/logger/logger_test.result
Normal file
17
pkg/util/logger/logger_test.result
Normal file
|
@ -0,0 +1,17 @@
|
|||
warning: GOPATH set to GOROOT (/home/annikifa/workspace/go/go1.22.6/) has no effect
|
||||
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
|
||||
10000 518.1 ns/op 23 B/op 0 allocs/op
|
||||
10000 523.6 ns/op 23 B/op 0 allocs/op
|
||||
10000 526.7 ns/op 23 B/op 0 allocs/op
|
||||
10000 513.5 ns/op 22 B/op 0 allocs/op
|
||||
10000 520.5 ns/op 23 B/op 0 allocs/op
|
||||
10000 517.5 ns/op 23 B/op 0 allocs/op
|
||||
10000 517.6 ns/op 23 B/op 0 allocs/op
|
||||
10000 623.3 ns/op 23 B/op 0 allocs/op
|
||||
10000 517.7 ns/op 23 B/op 0 allocs/op
|
||||
10000 654.9 ns/op 23 B/op 0 allocs/op
|
||||
PASS
|
||||
ok git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger 0.065s
|
Loading…
Add table
Add a link
Reference in a new issue