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

Remove overhead of default InstrumentedFunction #163

Merged
merged 1 commit into from
Apr 24, 2023

Conversation

jipolanco
Copy link
Contributor

I recently found out about the very nice "instrumented function" feature introduced by @ericphanson in #152.

After trying it out, I noticed that by default it has some additional overhead and allocations associated to the creation of the string representation of the instrumented function using repr. The overhead disappears when one directly passes a string instead of using the default.

Here is a small example:

using TimerOutputs
using BenchmarkTools

identity_timed(x, to) = to(identity)(x)
identity_timed_alt(x, to) = to(identity, "identity")(x)

to = TimerOutput()
x = 3
@btime identity_timed($x, $to)       #  668.241 ns (4 allocations: 192 bytes)
@btime identity_timed_alt($x, $to)   #  47.087 ns (0 allocations: 0 bytes)

This PR completely removes the overhead in the first case, by using a generated function when possible to generate the function name.

@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2023

Codecov Report

Patch coverage: 83.33% and project coverage change: +3.14 🎉

Comparison is base (4ff422a) 88.73% compared to head (c291d79) 91.87%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #163      +/-   ##
==========================================
+ Coverage   88.73%   91.87%   +3.14%     
==========================================
  Files           5        5              
  Lines         426      431       +5     
==========================================
+ Hits          378      396      +18     
+ Misses         48       35      -13     
Impacted Files Coverage Δ
src/utilities.jl 93.58% <83.33%> (+1.69%) ⬆️

... and 3 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@KristofferC KristofferC merged commit f088c5f into KristofferC:master Apr 24, 2023
@jipolanco jipolanco deleted the jip/instrumented branch April 24, 2023 08:17
fatteneder pushed a commit to fatteneder/TimerOutputs.jl that referenced this pull request Sep 18, 2023
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.

3 participants