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

Function BenchmarkWithoutFields

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

Source from the content-addressed store, hash-verified

283}
284
285func BenchmarkWithoutFields(b *testing.B) {
286 b.Logf("Logging without any structured context.")
287 b.Run("Zap", func(b *testing.B) {
288 logger := newZapLogger(zap.DebugLevel)
289 b.ResetTimer()
290 b.RunParallel(func(pb *testing.PB) {
291 for pb.Next() {
292 logger.Info(getMessage(0))
293 }
294 })
295 })
296 b.Run("Zap.Check", func(b *testing.B) {
297 logger := newZapLogger(zap.DebugLevel)
298 b.ResetTimer()
299 b.RunParallel(func(pb *testing.PB) {
300 for pb.Next() {
301 if ce := logger.Check(zap.InfoLevel, getMessage(0)); ce != nil {
302 ce.Write()
303 }
304 }
305 })
306 })
307 b.Run("Zap.CheckSampled", func(b *testing.B) {
308 logger := newSampledLogger(zap.DebugLevel)
309 b.ResetTimer()
310 b.RunParallel(func(pb *testing.PB) {
311 i := 0
312 for pb.Next() {
313 i++
314 if ce := logger.Check(zap.InfoLevel, getMessage(i)); ce != nil {
315 ce.Write()
316 }
317 }
318 })
319 })
320 b.Run("Zap.Sugar", func(b *testing.B) {
321 logger := newZapLogger(zap.DebugLevel).Sugar()
322 b.ResetTimer()
323 b.RunParallel(func(pb *testing.PB) {
324 for pb.Next() {
325 logger.Info(getMessage(0))
326 }
327 })
328 })
329 b.Run("Zap.SugarFormatting", func(b *testing.B) {
330 logger := newZapLogger(zap.DebugLevel).Sugar()
331 b.ResetTimer()
332 b.RunParallel(func(pb *testing.PB) {
333 for pb.Next() {
334 logger.Infof("%v %v %v %s %v %v %v %v %v %s\n", fakeFmtArgs()...)
335 }
336 })
337 })
338 b.Run("apex/log", func(b *testing.B) {
339 logger := newApexLog()
340 b.ResetTimer()
341 b.RunParallel(func(pb *testing.PB) {
342 for pb.Next() {

Callers

nothing calls this directly

Calls 15

newZapLoggerFunction · 0.85
newSampledLoggerFunction · 0.85
fakeFmtArgsFunction · 0.85
newApexLogFunction · 0.85
newKitLogFunction · 0.85
newLog15Function · 0.85
newLogrusFunction · 0.85
newZerologFunction · 0.85
newSlogFunction · 0.85
NextMethod · 0.80
SugarMethod · 0.80
getMessageFunction · 0.70

Tested by

no test coverage detected