Skip to content

Commit 9b41541

Browse files
committed
add GC time
1 parent ae63d2b commit 9b41541

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/execution.jl

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,17 @@ macro btime(args...)
572572
local $trialmin = $BenchmarkTools.minimum($trial)
573573
local $trialmean = $BenchmarkTools.mean($trial)
574574
local $trialallocs = $BenchmarkTools.allocs($trialmin)
575-
println(" min ", $BenchmarkTools.prettytime($BenchmarkTools.time($trialmin)),
576-
", mean ", $BenchmarkTools.prettytime($BenchmarkTools.time($trialmean)),
577-
" (", $trialallocs , " allocation",
578-
$trialallocs == 1 ? "" : "s",
579-
$trialallocs == 0 ? "" : ": " *
580-
$BenchmarkTools.prettymemory($BenchmarkTools.memory($trialmin)),
581-
")")
575+
$print(" min ", $BenchmarkTools.prettytime($BenchmarkTools.time($trialmin)),
576+
", mean ", $BenchmarkTools.prettytime($BenchmarkTools.time($trialmean)),
577+
" (", $trialallocs , " allocation", $trialallocs == 1 ? "" : "s")
578+
if $trialallocs == 0
579+
$println(")")
580+
else
581+
$println(", ", $prettymemory($memory($trialmin)),
582+
". GC mean ", $prettytime($gctime($trialmean); short=true),
583+
", ", $prettypercent($gctime($trialmean) / $time($trialmean)), ")"
584+
)
585+
end
582586
$result
583587
end)
584588
end

src/trials.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function prettydiff(p)
253253
return string(diff >= 0.0 ? "+" : "", @sprintf("%.2f", diff * 100), "%")
254254
end
255255

256-
function prettytime(t)
256+
function prettytime(t; short=false)
257257
if t < 1e3
258258
value, units = t, "ns"
259259
elseif t < 1e6
@@ -263,7 +263,11 @@ function prettytime(t)
263263
else
264264
value, units = t / 1e9, "s"
265265
end
266-
return string(@sprintf("%.3f", value), " ", units)
266+
if short
267+
string(@sprintf("%.0f", value), " ", units)
268+
else
269+
string(@sprintf("%.3f", value), " ", units)
270+
end
267271
end
268272

269273
function prettymemory(b)

0 commit comments

Comments
 (0)