From 6a5a95b1ed2d75bd548d8d33c0b6bb55c384496c Mon Sep 17 00:00:00 2001 From: EROMOSELE AKHIGBE Date: Wed, 17 Jul 2024 22:06:44 +0100 Subject: [PATCH] added benchmark for zerolog --- bridges/otelzerolog/hook_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bridges/otelzerolog/hook_test.go b/bridges/otelzerolog/hook_test.go index 27f23a4a192..9a610297b66 100644 --- a/bridges/otelzerolog/hook_test.go +++ b/bridges/otelzerolog/hook_test.go @@ -187,3 +187,17 @@ func TestConvertLevel(t *testing.T) { }) } } + +func BenchmarkHookRun(b *testing.B) { + rec := logtest.NewRecorder() + hook := NewHook(loggerName, WithLoggerProvider(rec)) + logger := zerolog.New(nil).Hook(hook) + level := zerolog.InfoLevel + msg := "benchmark log message" + event := logger.Info() + b.ResetTimer() + b.ReportAllocs() + for i := 0; i < b.N; i++ { + hook.Run(event, level, msg) + } +}