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

Fix timev compilation time tracking and add tests #46100

Merged
merged 3 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions base/timing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,11 @@ macro timev(msg, ex)
Experimental.@force_compile
local stats = gc_num()
local elapsedtime = time_ns()
cumulative_compile_timing(true)
local compile_elapsedtimes = cumulative_compile_time_ns()
local val = @__tryfinally($(esc(ex)),
(elapsedtime = time_ns() - elapsedtime;
cumulative_compile_timing(false);
compile_elapsedtimes = cumulative_compile_time_ns() .- compile_elapsedtimes)
)
local diff = GC_Diff(gc_num(), stats)
Expand Down
32 changes: 31 additions & 1 deletion test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ macro capture_stdout(ex)
end
end

# compilation reports in @time
# compilation reports in @time, @timev
let f = gensym("f"), callf = gensym("callf"), call2f = gensym("call2f")
@eval begin
$f(::Real) = 1
Expand Down Expand Up @@ -397,6 +397,36 @@ let f = gensym("f"), callf = gensym("callf"), call2f = gensym("call2f")
@test occursin("% of which was recompilation", out)
end
end
let f = gensym("f"), callf = gensym("callf"), call2f = gensym("call2f")
@eval begin
$f(::Real) = 1
$callf(container) = $f(container[1])
$call2f(container) = $callf(container)
c64 = [1.0]
c32 = [1.0f0]
cabs = AbstractFloat[1.0]

out = @capture_stdout @timev $call2f(c64)
@test occursin("% compilation time", out)
out = @capture_stdout @timev $call2f(c64)
@test occursin("% compilation time", out) == false

out = @capture_stdout @timev $call2f(c32)
@test occursin("% compilation time", out)
out = @capture_stdout @timev $call2f(c32)
@test occursin("% compilation time", out) == false

out = @capture_stdout @timev $call2f(cabs)
@test occursin("% compilation time", out)
out = @capture_stdout @timev $call2f(cabs)
@test occursin("% compilation time", out) == false

$f(::Float64) = 2
out = @capture_stdout @timev $call2f(c64)
@test occursin("% compilation time:", out)
@test occursin("% of which was recompilation", out)
end
end

# interactive utilities

Expand Down