Skip to content

Commit 29fa0ba

Browse files
authored
Switch to texthighlighter to unbreak profile (#2891)
* Updates to core/profile for PrettyTables 3
1 parent 6c6977f commit 29fa0ba

2 files changed

Lines changed: 20 additions & 19 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ LinearAlgebra = "1"
7676
Logging = "1"
7777
NVTX = "1"
7878
Preferences = "1"
79-
PrettyTables = "2"
79+
PrettyTables = "3"
8080
Printf = "1"
8181
Random = "1"
8282
Random123 = "1.2"

src/profile.jl

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -660,15 +660,15 @@ function Base.show(io::IO, results::ProfileResults)
660660
p75 = quantile(relevant_times, 0.75)
661661
p95 = quantile(relevant_times, 0.95)
662662

663-
highlight_p95 = Highlighter((data, i, j) -> (names(data)[j] == "time") &&
664-
(data[i,j] >= p95),
665-
crayon"red")
666-
highlight_p75 = Highlighter((data, i, j) -> (names(data)[j] == "time") &&
667-
(data[i,j] >= p75),
668-
crayon"yellow")
669-
highlight_bold = Highlighter((data, i, j) -> (names(data)[j] == "name") &&
670-
(data[!, :time][i] >= p75),
671-
crayon"bold")
663+
highlight_p95 = TextHighlighter((data, i, j) -> (names(data)[j] == "time") &&
664+
(data[i,j] >= p95),
665+
crayon"red")
666+
highlight_p75 = TextHighlighter((data, i, j) -> (names(data)[j] == "time") &&
667+
(data[i,j] >= p75),
668+
crayon"yellow")
669+
highlight_bold = TextHighlighter((data, i, j) -> (names(data)[j] == "name") &&
670+
(data[!, :time][i] >= p75),
671+
crayon"bold")
672672

673673
(highlight_p95, highlight_p75, highlight_bold)
674674
end
@@ -829,8 +829,9 @@ function Base.show(io::IO, results::ProfileResults)
829829
end
830830
end
831831
highlighters = time_highlighters(df)
832-
pretty_table(io, df; header, alignment, formatters, highlighters, crop,
833-
body_hlines=trace_divisions)
832+
highlighters = isempty(highlighters) ? PrettyTables.TextHighlighter[] : collect(highlighters)
833+
pretty_table(io, df; column_labels=header, alignment, formatters=[formatters], highlighters, fit_table_in_display_horizontally = (crop==:horizontal), fit_table_in_display_vertically=false)#,
834+
#body_hlines=trace_divisions)
834835
else
835836
df = summarize_trace(df)
836837

@@ -844,7 +845,7 @@ function Base.show(io::IO, results::ProfileResults)
844845
header = [summary_column_names[name] for name in names(df)]
845846
alignment = [name in ["name", "time_dist"] ? :l : :r for name in names(df)]
846847
highlighters = time_highlighters(df)
847-
pretty_table(io, df; header, alignment, formatters=summary_formatter(df), highlighters, crop)
848+
pretty_table(io, df; column_labels=header, alignment, formatters=[summary_formatter(df)], highlighters=collect(highlighters), fit_table_in_display_horizontally=(crop==:horizontal), fit_table_in_display_vertically=false)
848849
end
849850
end
850851

@@ -929,8 +930,8 @@ function Base.show(io::IO, results::ProfileResults)
929930
end
930931
end
931932
highlighters = time_highlighters(df)
932-
pretty_table(io, df; header, alignment, formatters, highlighters, crop,
933-
body_hlines=trace_divisions)
933+
pretty_table(io, df; column_labels=header, alignment, formatters=[formatters], highlighters=collect(highlighters), fit_table_in_display_horizontally=(crop==:horizontal), fit_table_in_display_vertically=false)
934+
#body_hlines=trace_divisions)
934935
else
935936
df = summarize_trace(results.device)
936937

@@ -944,7 +945,7 @@ function Base.show(io::IO, results::ProfileResults)
944945
header = [summary_column_names[name] for name in names(df)]
945946
alignment = [name in ["name", "time_dist"] ? :l : :r for name in names(df)]
946947
highlighters = time_highlighters(df)
947-
pretty_table(io, df; header, alignment, formatters=summary_formatter(df), highlighters, crop)
948+
pretty_table(io, df; column_labels=header, alignment, formatters=[summary_formatter(df)], highlighters=collect(highlighters), fit_table_in_display_horizontally=(crop==:horizontal), fit_table_in_display_vertically=false)
948949
end
949950
end
950951

@@ -981,7 +982,7 @@ function Base.show(io::IO, results::ProfileResults)
981982
for color in unique(df.color)
982983
if color !== nothing
983984
ids = df[df.color .== color, :id]
984-
highlighter = Highlighter(Crayon(; foreground=color)) do data, i, j
985+
highlighter = TextHighlighter(Crayon(; foreground=color)) do data, i, j
985986
names(data)[j] in ["name", "domain"] && data[!, :id][i] in ids
986987
end
987988
push!(color_highlighters, highlighter)
@@ -1002,7 +1003,7 @@ function Base.show(io::IO, results::ProfileResults)
10021003
end
10031004
end
10041005
highlighters = tuple(color_highlighters..., time_highlighters(df)...)
1005-
pretty_table(io, df; header, alignment, formatters, highlighters, crop)
1006+
pretty_table(io, df; column_labels=header, alignment, formatters=[formatters], highlighters=collect(highlighters), fit_table_in_display_horizontally=(crop==:horizontal), fit_table_in_display_vertically=false)
10061007
else
10071008
# merge the domain and name into a single column
10081009
nvtx_ranges.name = map(nvtx_ranges.name, nvtx_ranges.domain) do name, domain
@@ -1025,7 +1026,7 @@ function Base.show(io::IO, results::ProfileResults)
10251026
header = [summary_column_names[name] for name in names(df)]
10261027
alignment = [name in ["name", "time_dist"] ? :l : :r for name in names(df)]
10271028
highlighters = time_highlighters(df)
1028-
pretty_table(io, df; header, alignment, formatters=summary_formatter(df), highlighters, crop)
1029+
pretty_table(io, df; column_labels=header, alignment, formatters=[summary_formatter(df)], highlighters=collect(highlighters), fit_table_in_display_horizontally=(crop==:horizontal), fit_table_in_display_vertically=false)
10291030
end
10301031
end
10311032

0 commit comments

Comments
 (0)