Skip to content

Commit 5c496df

Browse files
fixup! Drop Formatting.jl
1 parent 0fec8ed commit 5c496df

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/LinuxPerf.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ struct Counters
359359
counters::Vector{Counter}
360360
end
361361

362-
addcommas(i::Int) = addcommas(string(i))
363-
function addcommas(s::String)
362+
_addcommas(i::Int) = _addcommas(string(i))
363+
function _addcommas(s::String)
364364
len = length(s)
365365
t = ""
366366
for i in 1:3:len
@@ -383,7 +383,7 @@ function Base.show(io::IO, c::Counters)
383383
stats = mapreduce(vcat, c.counters) do c
384384
c.enabled == 0 ? ["never enabled" "0 %"] :
385385
c.running == 0 ? ["did not run" "0 %"] :
386-
[addcommas(Int64(c.value)) @sprintf("%.1f %%", 100*(c.running/c.enabled))]
386+
[_addcommas(Int64(c.value)) @sprintf("%.1f %%", 100*(c.running/c.enabled))]
387387
end
388388
return pretty_table(io, stats, header=["Events", "Active Time"], row_labels=events, alignment=:l, crop=:none, body_hlines=collect(axes(stats, 1)))
389389
end

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,13 @@ end
9797
@pstats "cpu-cycles,(instructions,branch-instructions,branch-misses),(task-clock,context-switches,cpu-migrations,page-faults),(L1-dcache-load-misses,L1-dcache-loads,L1-icache-load-misses),(dTLB-load-misses,dTLB-loads)" foo!(dest, a, b, c)
9898
end
9999

100+
@testset "_addcommas" begin
101+
@test LinuxPerf._addcommas(1) == "1"
102+
@test LinuxPerf._addcommas(12) == "12"
103+
@test LinuxPerf._addcommas(123) == "123"
104+
@test LinuxPerf._addcommas(1234) == "1,234"
105+
@test LinuxPerf._addcommas(12345) == "12,345"
106+
@test LinuxPerf._addcommas(typemin(Int64)) == "-9,223,372,036,854,775,808"
107+
end
100108

101109
end

0 commit comments

Comments
 (0)