Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay evaluation of signpost arguments. #33

Merged
merged 1 commit into from
Mar 2, 2024
Merged

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Mar 2, 2024

This makes signpost usage really cheap when the logger is disabled:

julia> @benchmark @signpost_event log=OSLog(enabled=false) "disabled event"
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min  max):  3.125 ns  15.250 ns  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     3.208 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   3.270 ns ±  0.248 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

    ▃ █ ▃ ▂ ▁            ▄ ▂                                 ▁
  ▅▁█▁█▁█▁█▁█▁▇▁▁▇▁▅▁▄▁▆▁█▁█▁▆▁▁█▁▄▁▄▁▄▁▄▁▄▁▅▁▁▃▁▃▁▃▁▄▁▄▁▅▁▃ █
  3.12 ns      Histogram: log(frequency) by time     4.25 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

julia> @benchmark @signpost_interval log=OSLog(enabled=false) "disabled interval" begin end
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min  max):  3.500 ns  16.000 ns  ┊ GC (min  max): 0.00%  0.00%
 Time  (median):     4.667 ns              ┊ GC (median):    0.00%
 Time  (mean ± σ):   4.816 ns ±  0.721 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

            ▇ ▇  ▆ █  ▃ ▃  ▄ ▆  ▁
  ▁▁▁▁▁▂▃█▆▇█▇██▇██████▆█▆▆█▇█▆▆█▄▆▃▃▄▃▄▂▂▃▂▃▂▂▂▂▂▂▂▃▂▃▁▁▂▁▁ ▃
  3.5 ns         Histogram: frequency by time        6.88 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

Maybe we should do something similar for OSLog, but I don't have a convenient API in mind...

Copy link

codecov bot commented Mar 2, 2024

Codecov Report

Attention: Patch coverage is 94.87179% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 73.23%. Comparing base (a1caf44) to head (965f5a1).

Files Patch % Lines
src/os.jl 94.87% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
+ Coverage   72.80%   73.23%   +0.43%     
==========================================
  Files          10       10              
  Lines         717      736      +19     
==========================================
+ Hits          522      539      +17     
- Misses        195      197       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maleadt maleadt merged commit 87af4dc into master Mar 2, 2024
7 checks passed
@maleadt maleadt deleted the tb/lazy_signposts branch March 2, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant