Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 2.73 KB

README.md

File metadata and controls

34 lines (22 loc) · 2.73 KB

Benchmark Results

Benchmarks of slogx.Logger using optimal selection of Logger.With or Logger.WithLongTerm method calls

Performance of slogx.Logger compared to slog.Logger with slog.JSONHandler as a backend. Logger's WithLongTerm method is used in all LogAfterWith tests, as it is an optimal strategy for this use case. Values are in nanoseconds per operation.

Benchmark

Benchmarks of slogx.Logger using only Logger.With method calls

Performance of slogx.Logger compared to slog.Logger with slog.JSONHandler as a backend. Logger's WithLongTerm method is never used in these tests, so LogAfterWith tests have significant performance degradation. But at the same time in many other cases especially when the handler is disabled performance is significantly improved. For optimal performance use WithLongTerm when the resulting logger is planned to be used more than 3-4 times. Values are in nanoseconds per operation.

Benchmark

Benchmarks of slogx.Logger using only Logger.WithLongTerm method calls

Performance of slogx.Logger compared to slog.Logger with slog.JSONHandler as a backend. Logger's WithLongTerm method is always used in these tests, so LogAfterWith tests do not have significant performance degradation. But at the same time there is no significant performance improvements in other use cases as well. For optimal performance use WithLongTerm when the resulting logger is planned to be used more than 3-4 times. Values are in nanoseconds per operation.

Benchmark

Benchmarks of usage context.Context with slogc package instead of slogx.Logger

Performance comparison of slogc usage against slogx.Logger with optimal usage of WithLongTerm calls. Values are in nanoseconds per operation.

Benchmark