aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers/annotate.c
diff options
context:
space:
mode:
authorJin Yao <yao.jin@linux.intel.com>2017-05-04 10:58:15 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-06-19 14:14:57 -0400
commitec27ae1892f7f8119ce82535ffcc2889ea3bb3d8 (patch)
treef56ff28a18fe56cc5edcbb1616a9a6083c624d7c /tools/perf/ui/browsers/annotate.c
parentc564f0db92b7f8d734ce530e42a540e12ae3d583 (diff)
perf annotate browser: Display titles in left frame
The annotate browser is divided into 2 frames. Left frame contains 3 columns (some platforms only have one column). For example: │26 int compute_flag() │27 { 22.80 1.20 │ sub $0x8,%rsp │25 int i; │ │27 i = rand() % 2; 22.78 1.20 1 │ → callq rand@plt While it's hard for user to understand what the data is. This patch adds the titles "Percent", "IPC" and "Cycle" on columns. Percent IPC Cycle │ │25 __attribute__((noinline)) │26 int compute_flag() │27 { 22.80 1.20 │ sub $0x8,%rsp │25 int i; │ │27 i = rand() % 2; 22.78 1.20 1 │ → callq rand@plt The titles are displayed at row 0 of annotate browser if row 0 doesn't have values of percent, ipc and cycle. Signed-off-by: Yao Jin <yao.jin@linux.intel.com> Acked-by: Milian Wolff <milian.wolff@kdab.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Yao Jin <yao.jin@linux.intel.com> Link: http://lkml.kernel.org/r/1493909895-9668-3-git-send-email-yao.jin@linux.intel.com 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.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 52c1e8d672b5..7a03389b7a03 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -125,12 +125,21 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
125 int i, pcnt_width = annotate_browser__pcnt_width(ab); 125 int i, pcnt_width = annotate_browser__pcnt_width(ab);
126 double percent_max = 0.0; 126 double percent_max = 0.0;
127 char bf[256]; 127 char bf[256];
128 bool show_title = false;
128 129
129 for (i = 0; i < ab->nr_events; i++) { 130 for (i = 0; i < ab->nr_events; i++) {
130 if (bdl->samples[i].percent > percent_max) 131 if (bdl->samples[i].percent > percent_max)
131 percent_max = bdl->samples[i].percent; 132 percent_max = bdl->samples[i].percent;
132 } 133 }
133 134
135 if ((row == 0) && (dl->offset == -1 || percent_max == 0.0)) {
136 if (ab->have_cycles) {
137 if (dl->ipc == 0.0 && dl->cycles == 0)
138 show_title = true;
139 } else
140 show_title = true;
141 }
142
134 if (dl->offset != -1 && percent_max != 0.0) { 143 if (dl->offset != -1 && percent_max != 0.0) {
135 for (i = 0; i < ab->nr_events; i++) { 144 for (i = 0; i < ab->nr_events; i++) {
136 ui_browser__set_percent_color(browser, 145 ui_browser__set_percent_color(browser,
@@ -146,18 +155,27 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
146 } 155 }
147 } else { 156 } else {
148 ui_browser__set_percent_color(browser, 0, current_entry); 157 ui_browser__set_percent_color(browser, 0, current_entry);
149 ui_browser__write_nstring(browser, " ", 7 * ab->nr_events); 158
159 if (!show_title)
160 ui_browser__write_nstring(browser, " ", 7 * ab->nr_events);
161 else
162 ui_browser__printf(browser, "%*s", 7, "Percent");
150 } 163 }
151 if (ab->have_cycles) { 164 if (ab->have_cycles) {
152 if (dl->ipc) 165 if (dl->ipc)
153 ui_browser__printf(browser, "%*.2f ", IPC_WIDTH - 1, dl->ipc); 166 ui_browser__printf(browser, "%*.2f ", IPC_WIDTH - 1, dl->ipc);
154 else 167 else if (!show_title)
155 ui_browser__write_nstring(browser, " ", IPC_WIDTH); 168 ui_browser__write_nstring(browser, " ", IPC_WIDTH);
169 else
170 ui_browser__printf(browser, "%*s ", IPC_WIDTH - 1, "IPC");
171
156 if (dl->cycles) 172 if (dl->cycles)
157 ui_browser__printf(browser, "%*" PRIu64 " ", 173 ui_browser__printf(browser, "%*" PRIu64 " ",
158 CYCLES_WIDTH - 1, dl->cycles); 174 CYCLES_WIDTH - 1, dl->cycles);
159 else 175 else if (!show_title)
160 ui_browser__write_nstring(browser, " ", CYCLES_WIDTH); 176 ui_browser__write_nstring(browser, " ", CYCLES_WIDTH);
177 else
178 ui_browser__printf(browser, "%*s ", CYCLES_WIDTH - 1, "Cycle");
161 } 179 }
162 180
163 SLsmg_write_char(' '); 181 SLsmg_write_char(' ');