[#1619] logger: Add benchmark
Change-Id: I49e90e8a3689a755755afd0638b327a6b1884795 Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
af40b267e4
commit
dfdf2a9f58
2 changed files with 77 additions and 0 deletions
42
pkg/util/logger/logger_test.go
Normal file
42
pkg/util/logger/logger_test.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func BenchmarkLoggerDebug(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")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkLoggerError(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
prm := Prm{}
|
||||
require.NoError(b, prm.SetLevelString("error"))
|
||||
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")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue