[#1619] logger: Update benchmark
All checks were successful
DCO action / DCO (pull_request) Successful in 37s
Vulncheck / Vulncheck (pull_request) Successful in 1m4s
Build / Build Components (pull_request) Successful in 1m36s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m39s
Tests and linters / Run gofumpt (pull_request) Successful in 3m44s
Tests and linters / Lint (pull_request) Successful in 3m56s
Tests and linters / gopls check (pull_request) Successful in 4m5s
Tests and linters / Tests (pull_request) Successful in 4m34s
Tests and linters / Staticcheck (pull_request) Successful in 4m53s
Tests and linters / Tests with -race (pull_request) Successful in 5m5s
All checks were successful
DCO action / DCO (pull_request) Successful in 37s
Vulncheck / Vulncheck (pull_request) Successful in 1m4s
Build / Build Components (pull_request) Successful in 1m36s
Pre-commit hooks / Pre-commit (pull_request) Successful in 1m39s
Tests and linters / Run gofumpt (pull_request) Successful in 3m44s
Tests and linters / Lint (pull_request) Successful in 3m56s
Tests and linters / gopls check (pull_request) Successful in 4m5s
Tests and linters / Tests (pull_request) Successful in 4m34s
Tests and linters / Staticcheck (pull_request) Successful in 4m53s
Tests and linters / Tests with -race (pull_request) Successful in 5m5s
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
e1a1109ae5
commit
eed9e131dc
2 changed files with 158 additions and 16 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue