[#1619] logger: Update benchmark
All checks were successful
DCO action / DCO (pull_request) Successful in 36s
Vulncheck / Vulncheck (pull_request) Successful in 1m9s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m28s
Build / Build Components (pull_request) Successful in 1m36s
Tests and linters / Run gofumpt (pull_request) Successful in 3m11s
Tests and linters / Tests with -race (pull_request) Successful in 3m41s
Tests and linters / Staticcheck (pull_request) Successful in 3m51s
Tests and linters / gopls check (pull_request) Successful in 3m55s
Tests and linters / Tests (pull_request) Successful in 4m3s
Tests and linters / Lint (pull_request) Successful in 4m47s

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2025-03-06 11:25:00 +03:00
parent 0f89e7817c
commit e67f943a6d
2 changed files with 158 additions and 16 deletions

View file

@ -7,18 +7,88 @@ import (
"github.com/stretchr/testify/require"
)
func BenchmarkLogger(b *testing.B) {
func BenchmarkLoggerMain(b *testing.B) {
ctx := context.Background()
prm := Prm{}
require.NoError(b, prm.SetLevelString("debug"))
require.NoError(b, prm.SetAllowedTags([]string{"main: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")
}
}
func BenchmarkLoggerLevelLessTagAllowed(b *testing.B) {
ctx := context.Background()
prm := Prm{}
require.NoError(b, prm.SetLevelString("info"))
require.NoError(b, prm.SetAllowedTags([]string{"main: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")
}
}
func BenchmarkLoggerLevelGreaterTagAllowed(b *testing.B) {
ctx := context.Background()
prm := Prm{}
require.NoError(b, prm.SetLevelString("debug"))
require.NoError(b, prm.SetAllowedTags([]string{"main:info"}))
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")
}
}
func BenchmarkLoggerLevelLessTagDisabled(b *testing.B) {
ctx := context.Background()
prm := Prm{}
require.NoError(b, prm.SetLevelString("info"))
require.NoError(b, prm.SetAllowedTags([]string{"morph: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")
}
}
func BenchmarkLoggerLevelGreaterTagDisabled(b *testing.B) {
ctx := context.Background()
prm := Prm{}
require.NoError(b, prm.SetLevelString("debug"))
require.NoError(b, prm.SetAllowedTags([]string{"morph:info"}))
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")

View file

@ -1,17 +1,89 @@
warning: GOPATH set to GOROOT (/home/annikifa/workspace/go/go1.22.6/) has no effect
BenchmarkLoggerMain
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
10000 557.8 ns/op 23 B/op 0 allocs/op
10000 551.8 ns/op 23 B/op 0 allocs/op
10000 569.9 ns/op 23 B/op 0 allocs/op
10000 680.2 ns/op 22 B/op 0 allocs/op
10000 679.1 ns/op 22 B/op 0 allocs/op
10000 571.2 ns/op 23 B/op 0 allocs/op
10000 559.4 ns/op 22 B/op 0 allocs/op
10000 566.8 ns/op 23 B/op 0 allocs/op
10000 542.5 ns/op 22 B/op 0 allocs/op
10000 556.1 ns/op 23 B/op 0 allocs/op
PASS
ok git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger 0.065s
ok git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger 0.070s
BenchmarkLoggerLevelLessTagAllowed
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 551.8 ns/op 23 B/op 0 allocs/op
10000 542.7 ns/op 23 B/op 0 allocs/op
10000 567.0 ns/op 23 B/op 0 allocs/op
10000 547.2 ns/op 22 B/op 0 allocs/op
10000 542.9 ns/op 23 B/op 0 allocs/op
10000 569.4 ns/op 22 B/op 0 allocs/op
10000 563.3 ns/op 22 B/op 0 allocs/op
10000 553.4 ns/op 23 B/op 0 allocs/op
10000 550.0 ns/op 22 B/op 0 allocs/op
10000 599.5 ns/op 23 B/op 0 allocs/op
PASS
ok git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger 0.067s
BenchmarkLoggerLevelGreaterTagAllowed
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 526.6 ns/op 17 B/op 0 allocs/op
10000 418.6 ns/op 17 B/op 0 allocs/op
10000 434.5 ns/op 17 B/op 0 allocs/op
10000 495.0 ns/op 17 B/op 0 allocs/op
10000 423.5 ns/op 17 B/op 0 allocs/op
10000 426.1 ns/op 17 B/op 0 allocs/op
10000 416.9 ns/op 17 B/op 0 allocs/op
10000 435.2 ns/op 17 B/op 0 allocs/op
10000 422.6 ns/op 17 B/op 0 allocs/op
10000 416.1 ns/op 17 B/op 0 allocs/op
PASS
ok git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger 0.055s
BenchmarkLoggerLevelLessTagDisabled
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
BenchmarkLoggerLevelLessTagDisabled-8 10000 12.97 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelLessTagDisabled-8 10000 12.97 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelLessTagDisabled-8 10000 12.95 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelLessTagDisabled-8 10000 13.16 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelLessTagDisabled-8 10000 13.75 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelLessTagDisabled-8 10000 13.20 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelLessTagDisabled-8 10000 15.93 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelLessTagDisabled-8 10000 12.96 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelLessTagDisabled-8 10000 12.96 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelLessTagDisabled-8 10000 12.96 ns/op 0 B/op 0 allocs/op
PASS
ok git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger 0.010s
BenchmarkLoggerLevelGreaterTagDisabled
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
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 12.71 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 12.72 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 12.71 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 12.71 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 12.71 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 12.70 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 13.20 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 12.71 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 13.45 ns/op 0 B/op 0 allocs/op
BenchmarkLoggerLevelGreaterTagDisabled-8 10000 13.18 ns/op 0 B/op 0 allocs/op
PASS
ok git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger 0.011s