Skip to content

Commit

Permalink
Show human-readable time
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 committed Jun 21, 2020
1 parent c7b53b2 commit adee27f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/LinuxPerf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,21 @@ function Base.show(io::IO, stats::Stats)
@printf(io, " # %4.1f cycles per ns", counter.value / counter.running)
elseif name == "instructions" && haskey(stats, "cpu-cycles")
@printf(io, " # %4.1f insns per cycle", scaledcount(counter) / scaledcount(stats["cpu-cycles"]))
elseif name == "cpu-clock" || name == "task-clock"
clk = float(scaledcount(counter))
if clk 1e9
clk /= 1e9
unit = "s"
elseif clk 1e6
clk /= 1e6
unit = "ms"
elseif clk 1e3
clk /= 1e3
unit = "μs"
else
unit = "ns"
end
@printf(io, " # %4.1f %s", clk, unit)
else
for (num, den, label) in [
("stalled-cycles-frontend", "cpu-cycles", "cycles"),
Expand Down

0 comments on commit adee27f

Please sign in to comment.