Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/log: improve performance for disabled log levels (scionproto#4304)
Check if the log level is enabled before converting the log data with a call to convertCtx, to reduce the cost of the log call for disabled log levels. The following benchmark tests shows an improvement of the execution time from 135ns to 30ns with this change. ```go func BenchmarkLog(b *testing.B) { err := log.Setup(log.Config{Console: log.ConsoleConfig{Level: "info"}}) assert.NoError(b, err) for i := 0; i < b.N; i++ { log.Debug("hello world", "i", i) } } ```
- Loading branch information