Skip to content

Commit 128f97f

Browse files
committed
add GC time
1 parent d2e9ee8 commit 128f97f

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
@@ -568,13 +568,17 @@ macro btime(args...)
568568
local $trialmin = $BenchmarkTools.minimum($trial)
569569
local $trialmean = $BenchmarkTools.mean($trial)
570570
local $trialallocs = $BenchmarkTools.allocs($trialmin)
571-
println(" min ", $BenchmarkTools.prettytime($BenchmarkTools.time($trialmin)),
572-
", mean ", $BenchmarkTools.prettytime($BenchmarkTools.time($trialmean)),
573-
" (", $trialallocs , " allocation",
574-
$trialallocs == 1 ? "" : "s",
575-
$trialallocs == 0 ? "" : ": " *
576-
$BenchmarkTools.prettymemory($BenchmarkTools.memory($trialmin)),
577-
")")
571+
$print(" min ", $BenchmarkTools.prettytime($BenchmarkTools.time($trialmin)),
572+
", mean ", $BenchmarkTools.prettytime($BenchmarkTools.time($trialmean)),
573+
" (", $trialallocs , " allocation", $trialallocs == 1 ? "" : "s")
574+
if $trialallocs == 0
575+
$println(")")
576+
else
577+
$println(", ", $prettymemory($memory($trialmin)),
578+
". GC mean ", $prettytime($gctime($trialmean); short=true),
579+
", ", $prettypercent($gctime($trialmean) / $time($trialmean)), ")"
580+
)
581+
end
578582
$result
579583
end)
580584
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)