diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-07-28 12:19:32 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-07-28 12:19:32 -0400 |
commit | 3861c4a49bea432c57d6e7cbd89c8b71ed4445b7 (patch) | |
tree | e4207890d4d7394a9713a07bbeb0266bc70d856e /tools/perf/ui/browsers/annotate.c | |
parent | f67d395c6e3895c3c8c67c8f7523f6a94d61a82d (diff) |
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 <treeze.taeung@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-n2np5qcs20u6qjdr9orygne6@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 46f297a4e94b..80f38dab9c3a 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -110,7 +110,7 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br | |||
110 | 110 | ||
111 | static int annotate_browser__pcnt_width(struct annotate_browser *ab) | 111 | static int annotate_browser__pcnt_width(struct annotate_browser *ab) |
112 | { | 112 | { |
113 | return 7 * ab->nr_events; | 113 | return (annotate_browser__opts.show_total_period ? 12 : 7) * ab->nr_events; |
114 | } | 114 | } |
115 | 115 | ||
116 | static int annotate_browser__cycles_width(struct annotate_browser *ab) | 116 | 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 | |||
153 | bdl->samples[i].percent, | 153 | bdl->samples[i].percent, |
154 | current_entry); | 154 | current_entry); |
155 | if (annotate_browser__opts.show_total_period) { | 155 | if (annotate_browser__opts.show_total_period) { |
156 | ui_browser__printf(browser, "%6" PRIu64 " ", | 156 | ui_browser__printf(browser, "%11" PRIu64 " ", |
157 | bdl->samples[i].he.period); | 157 | bdl->samples[i].he.period); |
158 | } else { | 158 | } else { |
159 | ui_browser__printf(browser, "%6.2f ", | 159 | ui_browser__printf(browser, "%6.2f ", |
@@ -165,8 +165,10 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
165 | 165 | ||
166 | if (!show_title) | 166 | if (!show_title) |
167 | ui_browser__write_nstring(browser, " ", pcnt_width); | 167 | ui_browser__write_nstring(browser, " ", pcnt_width); |
168 | else | 168 | else { |
169 | ui_browser__printf(browser, "%*s", 7, annotate_browser__opts.show_total_period ? "Period" : "Percent"); | 169 | ui_browser__printf(browser, "%*s", pcnt_width, |
170 | annotate_browser__opts.show_total_period ? "Period" : "Percent"); | ||
171 | } | ||
170 | } | 172 | } |
171 | if (ab->have_cycles) { | 173 | if (ab->have_cycles) { |
172 | if (dl->ipc) | 174 | if (dl->ipc) |