rs / zerolog

Zero Allocation JSON Logger
MIT License
10.61k stars 572 forks source link

How's the performance of ConsoleWriter? #381

Open ten2ten2 opened 2 years ago

ten2ten2 commented 2 years ago

Could you please provide the performance of ConsoleWriter as well in the Benchmarks section? How is it compare to the performance of zap (sugared)?

rs commented 2 years ago

The consol writer is not performance optimized and is not meant to be used in production. You can PR a benchmark if you need it.

I'm not sure to understand the comparison with zap sugared.

phuslu commented 2 years ago

I have re-wrote a zerolog like logger and have a new console writer with performance improvment.

https://github.com/phuslu/log/blob/master/console.go#L15-L24 said,

// ConsoleWriter parses the JSON input and writes it in a colorized, human-friendly format to Writer.
// IMPORTANT: Don't use ConsoleWriter on critical path of a high concurrency and low latency application.
//
// Default output format:
//     {Time} {Level} {Goid} {Caller} > {Message} {Key}={Value} {Key}={Value}
//
// Note: The performance of ConsoleWriter is not good enough, because it will
// parses JSON input into structured records, then output in a specific order.
// Roughly 2x faster than logrus.TextFormatter, 0.8x fast as zap.ConsoleEncoder,
// and 5x faster than zerolog.ConsoleWriter.