diff --git a/README.md b/README.md index 3687bab..fbf0e7e 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,22 @@ Here's a quick demo: julia> using PkgCacheInspector julia> info_cachefile("Colors") -modules: Any[Colors] -68 external methods -1776 new specializations of external methods -371 external methods with new roots -5113 external targets -3796 edges -system: 2021616 -isbits: 2048623 -symbols: 13345 -tags: 28990 -relocations: 214509 -gvars: 5048 -fptrs: 3112 +Contents of /Users/user/.julia/compiled/v1.9/Colors/NKjaT_1DCqx.ji: + modules: Any[Colors] + 68 external methods + 1759 new specializations of external methods (Base 50.1%, ColorTypes 29.8%, Base.Broadcast 11.3%, ...) + 361 external methods with new roots + 5115 external targets + 3796 edges + file size: 4922032 (4.694 MiB) + Segment sizes (bytes): + system: 1971024 ( 46.65%) + isbits: 1998959 ( 47.31%) + symbols: 13360 ( 0.32%) + tags: 28804 ( 0.68%) + relocations: 213041 ( 5.04%) + gvars: 0 ( 0.00%) + fptrs: 0 ( 0.00%) ``` At the top of the display, you can see a summary of the numbers of various items: diff --git a/src/PkgCacheInspector.jl b/src/PkgCacheInspector.jl index 5fa27f0..67de494 100644 --- a/src/PkgCacheInspector.jl +++ b/src/PkgCacheInspector.jl @@ -18,6 +18,17 @@ struct PkgCacheSizes fptrlist::Int end +const cache_displaynames = [ + "system", + "isbits", + "symbols", + "tags", + "relocations", + "gvars", + "fptrs" + ] +const cache_displaynames_l = maximum(length, cache_displaynames) + function Base.show(io::IO, szs::PkgCacheSizes) indent = get(io, :indent, 0) nd = ntot = 0 @@ -27,20 +38,16 @@ function Base.show(io::IO, szs::PkgCacheSizes) nd = max(nd, ndigits(nb)) ntot += nb end - displaynames = [ - "system", - "isbits", - "symbols", - "tags", - "relocations", - "gvars", - "fptrs" - ] - l = maximum(length, displaynames) println(io, " "^indent, "Segment sizes (bytes):") for i = 1:nf nb = getfield(szs, i) - println(io, " "^indent, rpad(displaynames[i] * ": ", l+2), lpad(string(nb), nd), " (", @sprintf("% 6.2f", 100*nb/ntot), "%)") + println(io, + " "^indent, + rpad(cache_displaynames[i] * ": ", cache_displaynames_l+2), + lpad(string(nb), nd), + " (", + @sprintf("% 6.2f", 100*nb/ntot), + "%)") end end @@ -53,6 +60,7 @@ struct PkgCacheInfo new_method_roots::Vector{Any} external_targets::Vector{Any} edges::Vector{Any} + filesize::Int cachesizes::PkgCacheSizes end @@ -76,6 +84,7 @@ function Base.show(io::IO, info::PkgCacheInfo) !isempty(info.new_method_roots) && println(io, " ", length(info.new_method_roots) ÷ 2, " external methods with new roots") !isempty(info.external_targets) && println(io, " ", length(info.external_targets) ÷ 3, " external targets") !isempty(info.edges) && println(io, " ", length(info.edges) ÷ 2, " edges") + println(io, " ", rpad("file size: ", cache_displaynames_l+2), info.filesize, " (", Base.format_bytes(info.filesize),")") show(IOContext(io, :indent => 2), info.cachesizes) end @@ -96,7 +105,7 @@ function info_cachefile(path::String, depmods::Vector{Any}) if isa(sv, Exception) throw(sv) end - return PkgCacheInfo(path, sv[1:7]..., PkgCacheSizes(sv[8]...)) + return PkgCacheInfo(path, sv[1:7]..., filesize(path), PkgCacheSizes(sv[8]...)) end function info_cachefile(pkg::PkgId, path::String) diff --git a/test/runtests.jl b/test/runtests.jl index c9820d2..6579c2f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,4 +6,5 @@ using Test @test isa(info, PkgCacheInfo) str = sprint(show, info) @test occursin("relocations", str) && occursin("new specializations", str) && occursin("targets", str) + @test occursin("file size", str) end