MCPcopy
hub / github.com/uber-go/zap / BenchmarkDisabledWithoutFields

Function BenchmarkDisabledWithoutFields

benchmarks/scenario_bench_test.go:33–118  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

31)
32
33func BenchmarkDisabledWithoutFields(b *testing.B) {
34 b.Logf("Logging at a disabled level without any structured context.")
35 b.Run("Zap", func(b *testing.B) {
36 logger := newZapLogger(zap.ErrorLevel)
37 b.ResetTimer()
38 b.RunParallel(func(pb *testing.PB) {
39 for pb.Next() {
40 logger.Info(getMessage(0))
41 }
42 })
43 })
44 b.Run("Zap.Check", func(b *testing.B) {
45 logger := newZapLogger(zap.ErrorLevel)
46 b.ResetTimer()
47 b.RunParallel(func(pb *testing.PB) {
48 for pb.Next() {
49 if m := logger.Check(zap.InfoLevel, getMessage(0)); m != nil {
50 m.Write()
51 }
52 }
53 })
54 })
55 b.Run("Zap.Sugar", func(b *testing.B) {
56 logger := newZapLogger(zap.ErrorLevel).Sugar()
57 b.ResetTimer()
58 b.RunParallel(func(pb *testing.PB) {
59 for pb.Next() {
60 logger.Info(getMessage(0))
61 }
62 })
63 })
64 b.Run("Zap.SugarFormatting", func(b *testing.B) {
65 logger := newZapLogger(zap.ErrorLevel).Sugar()
66 b.ResetTimer()
67 b.RunParallel(func(pb *testing.PB) {
68 for pb.Next() {
69 logger.Infof("%v %v %v %s %v %v %v %v %v %s\n", fakeFmtArgs()...)
70 }
71 })
72 })
73 b.Run("apex/log", func(b *testing.B) {
74 logger := newDisabledApexLog()
75 b.ResetTimer()
76 b.RunParallel(func(pb *testing.PB) {
77 for pb.Next() {
78 logger.Info(getMessage(0))
79 }
80 })
81 })
82 b.Run("sirupsen/logrus", func(b *testing.B) {
83 logger := newDisabledLogrus()
84 b.ResetTimer()
85 b.RunParallel(func(pb *testing.PB) {
86 for pb.Next() {
87 logger.Info(getMessage(0))
88 }
89 })
90 })

Callers

nothing calls this directly

Calls 14

newZapLoggerFunction · 0.85
fakeFmtArgsFunction · 0.85
newDisabledApexLogFunction · 0.85
newDisabledLogrusFunction · 0.85
newDisabledZerologFunction · 0.85
newDisabledSlogFunction · 0.85
NextMethod · 0.80
SugarMethod · 0.80
getMessageFunction · 0.70
LogfMethod · 0.65
CheckMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected