Skip to content

Commit 8f868b6

Browse files
committed
stats: more compact printing, only percent for Compile/GC
1 parent e3259c8 commit 8f868b6

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

src/testset.jl

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ function print_test_results(ts::ReTestSet, fmt::Format;
202202
end
203203
if fmt.stats
204204
# copied from Julia/test/runtests.jl
205-
Compile = VERSION >= v"1.6-" ? "| Compile (s) " : ""
206-
printstyled("| Time (s) $Compile| GC (s) | GC % | Alloc (MB) | ΔRSS (MB)", color=:white)
205+
compile_header = VERSION >= v"1.6-" ? " Compile /" : ""
206+
printstyled("| Time /$compile_header GC | Alloc ΔRSS |", color=:white)
207207
end
208208
println()
209209
end
@@ -368,38 +368,29 @@ function print_counts(ts::ReTestSet, fmt::Format, depth, align,
368368
if fmt.stats && print_total # copied from Julia/test/runtests.jl
369369
ts.overall && set_timed!(ts)
370370
timed = ts.timed
371-
elapsed_align = textwidth("Time (s)")
372-
compile_align = textwidth("Compile (s)")
373-
gc_align = textwidth("GC (s)")
374-
percent_align = textwidth("GC %")
375-
alloc_align = textwidth("Alloc (MB)")
376-
rss_align = textwidth("ΔRSS (MB)")
377371

378372
# we don't want to report zeros, which makes it hard to spot non-zeros
379-
function hide_zero(str)
380-
len = length(str)
373+
function hide_zero(str, unit)
381374
strip(str, ' ') in ("0.0", "0.00") ?
382-
' '^length(str) :
383-
str
375+
' '^(1+length(str)) : # +1 for unit
376+
str * unit
384377
end
385378

386-
time_str = hide_zero(@sprintf("%7.2f", timed.time))
387-
printstyled("| ", lpad(time_str, elapsed_align, " "), " | ", color=:white)
379+
time_str = hide_zero(@sprintf("%6.2f", timed.time), "s")
380+
printstyled("| ", time_str, " ", color=:white)
388381
if VERSION >= v"1.6-"
389-
compile_str = hide_zero(@sprintf("%7.2f", timed.compile_time / 10^9))
390-
printstyled(lpad(compile_str, compile_align, " "), " | ", color=:white)
382+
compile_str = hide_zero(@sprintf("%5.1f", timed.compile_time / 10^7 / timed.time), "%")
383+
# can be >= 100% !?
384+
printstyled(compile_str, " ", color=:white)
391385
end
392-
gc_str = hide_zero(@sprintf("%5.2f", timed.gctime))
393-
printstyled(lpad(gc_str, gc_align, " "), " | ", color=:white)
394-
395-
# since there may be quite a few digits in the percentage,
396-
# the left-padding here is less to make sure everything fits
397-
percent_str = hide_zero(@sprintf("%4.1f", 100 * timed.gctime / timed.time))
398-
printstyled(lpad(percent_str, percent_align, " "), " | ", color=:white)
399-
alloc_str = hide_zero(@sprintf("%5.2f", timed.bytes / 2^20))
400-
printstyled(lpad(alloc_str, alloc_align, " "), " | ", color=:white)
401-
rss_str = hide_zero(@sprintf("%5.2f", timed.rss / 2^20))
402-
printstyled(lpad(rss_str, rss_align, " "), color=:white)
386+
gc_str = hide_zero(@sprintf("%4.1f", 100 * timed.gctime / timed.time), "%")
387+
printstyled(gc_str, " | ", color=:white)
388+
389+
alloc_str = hide_zero(@sprintf("%6.1f", timed.bytes / 2^20), "M")
390+
printstyled(alloc_str, " ", color=:white)
391+
392+
rss_str = hide_zero(@sprintf("%5.1f", timed.rss / 2^20), "M")
393+
printstyled(rss_str, " |", color=:white)
403394
end
404395
println()
405396

0 commit comments

Comments
 (0)