Skip to content

Commit

Permalink
Add benchmark for formatting a log
Browse files Browse the repository at this point in the history
  • Loading branch information
fasaxc committed Jul 22, 2024
1 parent 26971ee commit b3d8f44
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libcalico-go/lib/logutils/logutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,3 +564,16 @@ func BenchmarkRegexpStar(b *testing.B) {
BenchOut = BenchOut != re.MatchString("endpoint_mgr.go")
}
}

func BenchmarkLogWithOurFormat(b *testing.B) {
logger := log.New()
logger.SetFormatter(&Formatter{})
logger.SetReportCaller(true)
logger.SetOutput(&NullWriter{})

b.ResetTimer()

for i := 0; i < b.N; i++ {
logger.Info("Test log")
}
}

0 comments on commit b3d8f44

Please sign in to comment.