Skip to content

Commit 8602a74

Browse files
committed
Show human-readable time
1 parent cc755eb commit 8602a74

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
@@ -636,6 +636,21 @@ function Base.show(io::IO, stats::Stats)
636636
@printf(io, " # %4.1f cycles per ns", counter.value / counter.running)
637637
elseif name == "instructions" && haskey(stats, "cpu-cycles")
638638
@printf(io, " # %4.1f insns per cycle", scaledcount(counter) / scaledcount(stats["cpu-cycles"]))
639+
elseif name == "cpu-clock" || name == "task-clock"
640+
clk = float(scaledcount(counter))
641+
if clk 1e9
642+
clk /= 1e9
643+
unit = "s"
644+
elseif clk 1e6
645+
clk /= 1e6
646+
unit = "ms"
647+
elseif clk 1e3
648+
clk /= 1e3
649+
unit = "μs"
650+
else
651+
unit = "ns"
652+
end
653+
@printf(io, " # %4.1f %s", clk, unit)
639654
else
640655
for (num, den, label) in [
641656
("stalled-cycles-frontend", "cpu-cycles", "cycles"),

0 commit comments

Comments
 (0)