Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
FlameGraphs = "08572546-2f56-4bcf-ba4e-bab62c3a3f89"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Expand All @@ -17,7 +18,6 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
[weakdeps]
Cthulhu = "f68482b8-f384-11e8-15f7-abe071a5a75f"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"

[extensions]
Expand All @@ -35,7 +35,7 @@ JET = "0.9"
MethodAnalysis = "0.4"
OrderedCollections = "1"
Pkg = "1"
PrettyTables = "2"
PrettyTables = "2, 3"
Printf = "1"
Profile = "1"
PyPlot = "2"
Expand Down
53 changes: 39 additions & 14 deletions ext/SCPrettyTablesExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,52 @@ function SnoopCompile.report_invalidations(io::IO = stdout;
fileinfo = map(trees) do inv
"$(process_filename(string(inv.method.file))):$(inv.method.line)"
end
header = (
["<file name>:<line number>", "Function Name", "Invalidations", "Invalidations %"],
["", "", "", "(xᵢ/∑x)"],
)

table_data = hcat(
fileinfo,
meth_name,
invs_per_method,
n_invalidations_percent,
)

PrettyTables.pretty_table(
io,
table_data;
header,
formatters = PrettyTables.ft_printf("%s", 2:2),
header_crayon = PrettyTables.crayon"yellow bold",
subheader_crayon = PrettyTables.crayon"green bold",
crop = :none,
alignment = [:l, :c, :c, :c],
)
@static if pkgversion(PrettyTables).major == 2
header = (
["<file name>:<line number>", "Function Name", "Invalidations", "Invalidations %"],
["", "", "", "(xᵢ/∑x)"],
)

PrettyTables.pretty_table(
io,
table_data;
header,
formatters = PrettyTables.ft_printf("%s", 2:2),
header_crayon = PrettyTables.crayon"yellow bold",
subheader_crayon = PrettyTables.crayon"green bold",
crop = :none,
alignment = [:l, :c, :c, :c],
)
else
column_labels = [
["<file name>:<line number>", "Function Name", "Invalidations", "Invalidations %"],
["", "", "", "(xᵢ/∑x)"],
]

style = PrettyTables.TextTableStyle(
first_line_column_label = PrettyTables.crayon"yellow bold",
column_label = PrettyTables.crayon"green bold",
)

PrettyTables.pretty_table(
io,
table_data;
column_labels,
alignment = [:l, :c, :c, :c],
fit_table_in_display_horizontally = false,
fit_table_in_display_vertically = false,
formatters = [PrettyTables.fmt__printf("%s", [2])],
style
)
end
end

end
Loading