MCPcopy
hub / github.com/rs/zerolog / BenchmarkHooks

Function BenchmarkHooks

hook_test.go:271–298  ·  hook_test.go::BenchmarkHooks
(b *testing.B)

Source from the content-addressed store, hash-verified

269}
270
271func BenchmarkHooks(b *testing.B) {
272 logger := New(io.Discard)
273 b.ResetTimer()
274 b.Run("Nop/Single", func(b *testing.B) {
275 log := logger.Hook(nopHook)
276 b.RunParallel(func(pb *testing.PB) {
277 for pb.Next() {
278 log.Log().Msg("")
279 }
280 })
281 })
282 b.Run("Nop/Multi", func(b *testing.B) {
283 log := logger.Hook(nopHook).Hook(nopHook)
284 b.RunParallel(func(pb *testing.PB) {
285 for pb.Next() {
286 log.Log().Msg("")
287 }
288 })
289 })
290 b.Run("Simple", func(b *testing.B) {
291 log := logger.Hook(simpleHook)
292 b.RunParallel(func(pb *testing.PB) {
293 for pb.Next() {
294 log.Log().Msg("")
295 }
296 })
297 })
298}

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
HookMethod · 0.80
MsgMethod · 0.80
RunMethod · 0.65
NextMethod · 0.65
LogMethod · 0.65

Tested by

no test coverage detected