-
Notifications
You must be signed in to change notification settings - Fork 9
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
Is there a macro like Base.@timed
or BenchmarkTools.@btimed
?
#166
Comments
What is the specific use-case that motivates this? I generally recommend |
Hi @LilithHafner, thank you for your timely response! The use-case I am having is that I am calculating the same function executed given different input sizes, and I want to save the result and the timing information. You can think of an example like below: timed_results = map(100:100:1000) do iter
value, time = @btimed f($iter) samples=3
end Then, I want to plot the computed values or their time cost v.s. number of iterations. But the time could range from milliseconds to minutes, and the value accuracy could range from 1e-4 to 1e-9. I want to do all these things with a simple macro like The example you mentioned in the other issue: julia> x = Ref{Float64}()
Base.RefValue{Float64}(0.0)
julia> @b rand(100) sum x[] = _
12.166 ns
julia> x[]
52.6901305539253 requires to specify the type of |
You could use a There's a real, but not common usecase for this; I'll have to think about how I want to balance feature-rich-ness vs scope creep, maintainability, and concision of src and docs. |
Will the |
It will not be counted. This can also be easily verified: julia> x = Ref{Any}()
Base.RefValue{Any}(#undef)
julia> @b rand hash
2.554 ns
julia> @b rand hash x[] = _
2.563 ns
julia> x[]
0x376f126f3b0be0e8 |
Thanks for your help! Although I still think this syntax is a bit overdoing a simple thing. I would appreciate it if you could consider my request. |
I have another reason for returning the result: result = Ref{Any}()
@b a_very_long_function(
args...
) result[] = _ samples = 1 evals = 1 When we give arguments like |
According to
Base.@timed
docs,@timed
isSince version v1.6.0, BenchmarkTools.jl has added macro
@btimed
.I wonder if Chairmarks.jl has the same tool or has it planned. I am migrating from BenchmarkTools.jl to Chairmarks.jl, it would be nice to have the same tool without changing much of my code.
The text was updated successfully, but these errors were encountered: