instrument-bench
is a set of benchmarks comparing the overhead of various
logging and instrumentation crates. These include:
env_logger
tracing-subscriber
(with thefmt
subscriber layer)tracing-tracy
(this is used in combination withtracing-subscriber
just replacing thefmt
layer in these tests)
The backends/frontends listed here are benchmarked in all possible combinations since they are all compatible.
cargo bench
Note: I did not obtain these in a controlled environment and they can vary wildly (-50/+100 percent). However, the general relationships that are more than a factor of 2 apart should hold.
instrumentation | env_logger |
tracing-subscriber |
tracing-tracy |
---|---|---|---|
Level::Info |
|||
log::debug!("") |
1.6 ns | 1.6 ns | 1.9 ns |
tracing::debug!("") |
2.6 ns | 3.8 ns | 3.4 ns |
tracing::debug_span!("") |
39.4 ns | 13.9 ns | 14.4 ns |
tracing::debug_span!("", "extra info") |
48.3 ns | 18.7 ns | 15.0 ns |
"mycrate::foo=error" * |
|||
log::info!("") |
24.0 ns | 81.7 ns | 44.3 ns |
tracing::info!("") |
12.5 ns | 3.0 ns | 2.7 ns |
tracing::info_span!("") |
76.9 ns | 19.4 ns | 13.9 ns |
tracing::info_span!("", "extra info") |
86.32 ns | 19.7 ns | 14.5 ns |
*For the info_span!("")
"tracing::span=error" is needed to suppres it rather than using the module path because tracing spans report this as their module name to log
frontends for spans that have no extra fields attached.
tracing-subscriber
is using the fmt
subscriber layer with a tracing
span
tracy-tracing
allows timing tracing
spans with the Tracy profiler
tracy-client
directly interfaces with the Tracy profiler
crate | time (ns) |
---|---|
tracing-subscriber |
600 |
tracy-tracing |
1062 |
tracy-client |
205 |