Skip to content

Commit adee27f

Browse files
committed
Show human-readable time
1 parent c7b53b2 commit adee27f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/LinuxPerf.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,21 @@ function Base.show(io::IO, stats::Stats)
615615
@printf(io, " # %4.1f cycles per ns", counter.value / counter.running)
616616
elseif name == "instructions" && haskey(stats, "cpu-cycles")
617617
@printf(io, " # %4.1f insns per cycle", scaledcount(counter) / scaledcount(stats["cpu-cycles"]))
618+
elseif name == "cpu-clock" || name == "task-clock"
619+
clk = float(scaledcount(counter))
620+
if clk 1e9
621+
clk /= 1e9
622+
unit = "s"
623+
elseif clk 1e6
624+
clk /= 1e6
625+
unit = "ms"
626+
elseif clk 1e3
627+
clk /= 1e3
628+
unit = "μs"
629+
else
630+
unit = "ns"
631+
end
632+
@printf(io, " # %4.1f %s", clk, unit)
618633
else
619634
for (num, den, label) in [
620635
("stalled-cycles-frontend", "cpu-cycles", "cycles"),

0 commit comments

Comments
 (0)