Open
Description
A trivial example shows that the TransformerLogger
allocates even in the simplest case:
julia> using LoggingExtras, BenchmarkTools
julia> @benchmark @debug "foo"
BenchmarkTools.Trial: 10000 samples with 991 evaluations.
Range (min … max): 40.886 ns … 232.741 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 42.128 ns ┊ GC (median): 0.00%
Time (mean ± σ): 53.330 ns ± 20.183 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█▄▂▄▃▃▂▂▂▁▁ ▁▁ ▁
████████████████████████████▇▇█▇▇▇█▇███████████▇██▇▇▆▇▅▆▅▆▅▅ █
40.9 ns Histogram: log(frequency) by time 118 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> timestamp_logger(logger) = TransformerLogger(identity, logger);
julia> ConsoleLogger(stdout, Logging.Info) |> timestamp_logger |> global_logger;
julia> @benchmark @debug "foo"
BenchmarkTools.Trial: 10000 samples with 6 evaluations.
Range (min … max): 5.577 μs … 280.281 μs ┊ GC (min … max): 0.00% … 94.83%
Time (median): 5.905 μs ┊ GC (median): 0.00%
Time (mean ± σ): 7.087 μs ± 6.190 μs ┊ GC (mean ± σ): 1.79% ± 2.11%
▇█▅▄▄▄▃▃▃▃▃▃▃▃▃▃▂▁▁▁ ▁▁▁▁▁▁▂▁▁▁ ▂
████████████████████████▇▇▇▇▇▆▆▆▆▆▄▅▅▆▅▆▇▇██████████████▇▆▅ █
5.58 μs Histogram: log(frequency) by time 13.3 μs <
Memory estimate: 4.37 KiB, allocs estimate: 32.
This uses LoggingExtras v1.0.3 and Julia v1.10.0:
julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 4 × Intel(R) Xeon(R) Gold 6136 CPU @ 3.00GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, skylake-avx512)
Threads: 5 on 4 virtual cores
Environment:
JULIA_NUM_THREADS = 4
julia> using Pkg; Pkg.status("LoggingExtras")
Status `~/.julia/environments/v1.10/Project.toml`
[e6f89c97] LoggingExtras v1.0.3
Metadata
Metadata
Assignees
Labels
No labels