Skip to content

Commit b21f7ca

Browse files
committed
Add compilation % to debug timing display
But not on 1.10
1 parent b74fc08 commit b21f7ca

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

src/ParallelTestRunner.jl

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct TestRecord <: AbstractTestRecord
8686
time::Float64
8787
bytes::UInt64
8888
gctime::Float64
89+
compile_time::Float64
8990
rss::UInt64
9091
total_time::Float64
9192
end
@@ -111,14 +112,16 @@ struct TestIOContext
111112
lock::ReentrantLock
112113
name_align::Int
113114
elapsed_align::Int
115+
compile_align::Int
114116
gc_align::Int
115117
percent_align::Int
116118
alloc_align::Int
117119
rss_align::Int
118120
end
119121

120122
function test_IOContext(stdout::IO, stderr::IO, lock::ReentrantLock, name_align::Int, debug_timing::Bool)
121-
elapsed_align = textwidth("Time (s)")
123+
elapsed_align = textwidth("time (s)")
124+
compile_align = textwidth("Compile")
122125
gc_align = textwidth("GC (s)")
123126
percent_align = textwidth("GC %")
124127
alloc_align = textwidth("Alloc (MB)")
@@ -127,7 +130,7 @@ function test_IOContext(stdout::IO, stderr::IO, lock::ReentrantLock, name_align:
127130
color = get(stdout, :color, false)
128131

129132
return TestIOContext(
130-
stdout, stderr, color, debug_timing, lock, name_align, elapsed_align, gc_align, percent_align,
133+
stdout, stderr, color, debug_timing, lock, name_align, elapsed_align, compile_align, gc_align, percent_align,
131134
alloc_align, rss_align
132135
)
133136
end
@@ -137,15 +140,17 @@ function print_header(ctx::TestIOContext, testgroupheader, workerheader)
137140
try
138141
# header top
139142
printstyled(ctx.stdout, " "^(ctx.name_align + textwidth(testgroupheader) - 3), "")
140-
printstyled(ctx.stdout, " |", color = :white)
143+
printstyled(ctx.stdout, " Test |", color = :white)
141144
ctx.debug_timing && printstyled(ctx.stdout, " Init │", color = :white)
145+
VERSION >= v"1.11" && ctx.debug_timing && printstyled(ctx.stdout, " Compile │", color = :white)
142146
printstyled(ctx.stdout, " ──────────────── CPU ──────────────── │\n", color = :white)
143147

144148
# header bottom
145149
printstyled(ctx.stdout, testgroupheader, color = :white)
146150
printstyled(ctx.stdout, lpad(workerheader, ctx.name_align - textwidth(testgroupheader) + 1), "", color = :white)
147-
printstyled(ctx.stdout, "Time (s) │", color = :white)
151+
printstyled(ctx.stdout, "time (s) │", color = :white)
148152
ctx.debug_timing && printstyled(ctx.stdout, " time (s) │", color = :white)
153+
VERSION >= v"1.11" && ctx.debug_timing && printstyled(ctx.stdout, " (%) │", color = :white)
149154
printstyled(ctx.stdout, " GC (s) │ GC % │ Alloc (MB) │ RSS (MB) │\n", color = :white)
150155
flush(ctx.stdout)
151156
finally
@@ -177,8 +182,15 @@ function print_test_finished(record::TestRecord, wrkr, test, ctx::TestIOContext)
177182
printstyled(ctx.stdout, lpad(time_str, ctx.elapsed_align, " "), "", color = :white)
178183

179184
if ctx.debug_timing
185+
# pre-testset time
180186
init_time_str = @sprintf("%7.2f", record.total_time - record.time)
181187
printstyled(ctx.stdout, lpad(init_time_str, ctx.elapsed_align, " "), "", color = :white)
188+
189+
# compilation time
190+
if VERSION >= v"1.11"
191+
init_time_str = @sprintf("%7.2f", Float64(100*record.compile_time/record.time))
192+
printstyled(ctx.stdout, lpad(init_time_str, ctx.compile_align, " "), "", color = :white)
193+
end
182194
end
183195

184196
gc_str = @sprintf("%5.2f", record.gctime)
@@ -323,7 +335,9 @@ function runtest(f, name, init_code, start_time)
323335
$f
324336
end
325337
end
326-
(; testset=stats.value, stats.time, stats.bytes, stats.gctime)
338+
339+
compile_time = @static VERSION >= v"1.11" ? stats.compile_time : 0.0
340+
(; testset=stats.value, stats.time, stats.bytes, stats.gctime, compile_time)
327341
end
328342

329343
# process results

test/runtests.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ end
3232
runtests(ParallelTestRunner, ["--debug-timing"]; stdout=io_color, stderr=io_color)
3333
str = String(take!(io))
3434

35+
@test contains(str, "time (s)") # timing
36+
3537
@test contains(str, "Init") # debug timing
36-
@test contains(str, "time (s)") # debug timing
37-
@test contains(str, "Time (s)") # normal timing
38+
if VERSION >= v"1.11" # compile time as part of the struct not available before 1.11
39+
@test contains(str, "Compile") # debug timing
40+
@test contains(str, "(%)") # debug timing
41+
end
3842
end
3943

4044
@testset "default njobs" begin

0 commit comments

Comments
 (0)