Skip to content

Commit 952fddb

Browse files
committed
Add compilation % to debug timing display
1 parent 31f0286 commit 952fddb

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

src/ParallelTestRunner.jl

Lines changed: 15 additions & 7 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,15 @@ 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)
141-
ctx.debug_timing && printstyled(ctx.stdout, " Init │", color = :white)
143+
printstyled(ctx.stdout, " Test |", color = :white)
144+
ctx.debug_timing && printstyled(ctx.stdout, " Init │ Compile │", color = :white)
142145
printstyled(ctx.stdout, " ──────────────── CPU ──────────────── │\n", color = :white)
143146

144147
# header bottom
145148
printstyled(ctx.stdout, testgroupheader, color = :white)
146149
printstyled(ctx.stdout, lpad(workerheader, ctx.name_align - textwidth(testgroupheader) + 1), "", color = :white)
147-
printstyled(ctx.stdout, "Time (s) │", color = :white)
148-
ctx.debug_timing && printstyled(ctx.stdout, " time (s) │", color = :white)
150+
printstyled(ctx.stdout, "time (s) │", color = :white)
151+
ctx.debug_timing && printstyled(ctx.stdout, " time (s) │ (%) │", color = :white)
149152
printstyled(ctx.stdout, " GC (s) │ GC % │ Alloc (MB) │ RSS (MB) │\n", color = :white)
150153
flush(ctx.stdout)
151154
finally
@@ -177,8 +180,13 @@ function print_test_finished(record::TestRecord, wrkr, test, ctx::TestIOContext)
177180
printstyled(ctx.stdout, lpad(time_str, ctx.elapsed_align, " "), "", color = :white)
178181

179182
if ctx.debug_timing
183+
# pre-testset time
180184
init_time_str = @sprintf("%7.2f", record.total_time - time)
181185
printstyled(ctx.stdout, lpad(init_time_str, ctx.elapsed_align, " "), "", color = :white)
186+
187+
# compilation time
188+
init_time_str = @sprintf("%7.2f", Float64(100*record.compile_time/time))
189+
printstyled(ctx.stdout, lpad(init_time_str, ctx.compile_align, " "), "", color = :white)
182190
end
183191

184192
gc_str = @sprintf("%5.2f", record.gctime)
@@ -320,7 +328,7 @@ function runtest(f, name, init_code, start_time)
320328
$f
321329
end
322330
end
323-
(; testset=stats.value, stats.time, stats.bytes, stats.gctime)
331+
(; testset=stats.value, stats.time, stats.bytes, stats.gctime, stats.compile_time)
324332
end
325333

326334
# process results

test/runtests.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ end
3030
runtests(ParallelTestRunner, ["--debug-timing"]; stdout=io_color, stderr=io_color)
3131
str = String(take!(io))
3232

33+
@test contains(str, "time (s)") # timing
34+
3335
@test contains(str, "Init") # debug timing
34-
@test contains(str, "time (s)") # debug timing
35-
@test contains(str, "Time (s)") # normal timing
36+
@test contains(str, "Compile") # debug timing
37+
@test contains(str, "(%)") # debug timing
3638
end
3739

3840
@testset "subdir use" begin

0 commit comments

Comments
 (0)