-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add explanation about top-level compilation to timing macros #39802
Add explanation about top-level compilation to timing macros #39802
Conversation
To illustrate the need for this note julia> @eval function f(a) # Expensive function to compile. (Thanks @yuyichao!)
$(quote $([:(a = a + a * 10 + (a > 0 ? $i : 0.2)) for i in 1:401]...) end)
$(quote $([:(a = a + a * 10 + (a > 0 ? $i : 0.2)) for i in 1:401]...) end)
return a
end
f (generic function with 1 method)
julia> @time f(2)
0.000000 seconds julia> @eval function f(a) # Expensive function to compile. (Thanks @yuyichao!)
$(quote $([:(a = a + a * 10 + (a > 0 ? $i : 0.2)) for i in 1:401]...) end)
$(quote $([:(a = a + a * 10 + (a > 0 ? $i : 0.2)) for i in 1:401]...) end)
return a
end
f (generic function with 1 method)
julia> @time @eval f(2)
13.801006 seconds (6.26 M allocations: 317.365 MiB, 3.65% gc time, 100.02% compilation time) |
I wonder if there is some way that we can have the former expression hint that compile time was excluded. I guess we could have the REPL check if what you're evaling is a literal |
Looks good to me. :) |
What is the reason for the failure on linux32? Is this ready to be merged? |
Bump. |
@JeffBezanson @Keno What are your thoughts on this PR? |
Can this PR get a backport label? It would be nice to have it in 1.6 . |
Following discussions in #39760
Text based on @JeffBezanson's edits in JuliaLang/www.julialang.org@ef6846d