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

Function BenchmarkContextFields

benchmark_test.go:45–58  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

43}
44
45func BenchmarkContextFields(b *testing.B) {
46 logger := New(io.Discard).With().
47 Str("string", "four!").
48 Time("time", time.Time{}).
49 Int("int", 123).
50 Float32("float", -2.203230293249593).
51 Logger()
52 b.ResetTimer()
53 b.RunParallel(func(pb *testing.PB) {
54 for pb.Next() {
55 logger.Info().Msg(fakeMessage)
56 }
57 })
58}
59
60func BenchmarkContextAppend(b *testing.B) {
61 logger := New(io.Discard).With().

Callers

nothing calls this directly

Calls 10

NewFunction · 0.85
LoggerMethod · 0.80
WithMethod · 0.80
MsgMethod · 0.80
NextMethod · 0.65
InfoMethod · 0.65
Float32Method · 0.45
IntMethod · 0.45
TimeMethod · 0.45
StrMethod · 0.45

Tested by

no test coverage detected