Skip to content

Commit 3861c4a

Browse files
committed
perf annotate TUI: Set appropriate column width for period/percent
Either when we start 'perf annotate' or 'perf report' with --show-total-period or when we, in the annotate browser, press 't' to toggle period/percent for the first column, we need to adjust the width for the 'period' case. Based-on-a-patch-by: Taeung Song <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent f67d395 commit 3861c4a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tools/perf/ui/browsers/annotate.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br
110110

111111
static int annotate_browser__pcnt_width(struct annotate_browser *ab)
112112
{
113-
return 7 * ab->nr_events;
113+
return (annotate_browser__opts.show_total_period ? 12 : 7) * ab->nr_events;
114114
}
115115

116116
static int annotate_browser__cycles_width(struct annotate_browser *ab)
@@ -153,7 +153,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
153153
bdl->samples[i].percent,
154154
current_entry);
155155
if (annotate_browser__opts.show_total_period) {
156-
ui_browser__printf(browser, "%6" PRIu64 " ",
156+
ui_browser__printf(browser, "%11" PRIu64 " ",
157157
bdl->samples[i].he.period);
158158
} else {
159159
ui_browser__printf(browser, "%6.2f ",
@@ -165,8 +165,10 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
165165

166166
if (!show_title)
167167
ui_browser__write_nstring(browser, " ", pcnt_width);
168-
else
169-
ui_browser__printf(browser, "%*s", 7, annotate_browser__opts.show_total_period ? "Period" : "Percent");
168+
else {
169+
ui_browser__printf(browser, "%*s", pcnt_width,
170+
annotate_browser__opts.show_total_period ? "Period" : "Percent");
171+
}
170172
}
171173
if (ab->have_cycles) {
172174
if (dl->ipc)

0 commit comments

Comments
 (0)