aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers/annotate.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2015-07-18 11:24:51 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-06 15:37:22 -0400
commitf8f4aaead579c947fb8fc051c9d242037025caf3 (patch)
tree0835c664d541fff8e462735336dbf3081b7f116c /tools/perf/ui/browsers/annotate.c
parent30e863bb6f708c0abd422fbb0e6b295f5ee6407b (diff)
perf annotate: Finally display IPC and cycle accounting
Add two new columns to the annotate display and display the average cycles and the compute IPC if available. When the LBR was not in any branch mode the IPC computation is automatically disabled. We still display the cycle information. Example output (with made up numbers): The second column is the IPC and third average cycles. │ __attribute__((noinline)) f2() │ { 5.15 0.07 │ push %rbp 0.01 0.07 │ mov %rsp,%rbp │ c = a / b; 9.87 0.07 │ mov a,%eax 0.07 │ mov b,%ecx 0.07 │ cltd 4.92 0.07 123│ idiv %ecx 70.79 0.07 │ mov %eax,__TMC_END__ │ } 9.25 0.07 │ pop %rbp 0.01 0.07 123│ ← retq v2: Fix display problems. Signed-off-by: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1437233094-12844-7-git-send-email-andi@firstfloor.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.c57
1 files changed, 40 insertions, 17 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 6ec179547f72..b5fc847f9660 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -16,6 +16,9 @@ struct disasm_line_samples {
16 u64 nr; 16 u64 nr;
17}; 17};
18 18
19#define IPC_WIDTH 6
20#define CYCLES_WIDTH 6
21
19struct browser_disasm_line { 22struct browser_disasm_line {
20 struct rb_node rb_node; 23 struct rb_node rb_node;
21 u32 idx; 24 u32 idx;
@@ -97,6 +100,15 @@ static int annotate_browser__set_jumps_percent_color(struct annotate_browser *br
97 return ui_browser__set_color(&browser->b, color); 100 return ui_browser__set_color(&browser->b, color);
98} 101}
99 102
103static int annotate_browser__pcnt_width(struct annotate_browser *ab)
104{
105 int w = 7 * ab->nr_events;
106
107 if (ab->have_cycles)
108 w += IPC_WIDTH + CYCLES_WIDTH;
109 return w;
110}
111
100static void annotate_browser__write(struct ui_browser *browser, void *entry, int row) 112static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
101{ 113{
102 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); 114 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
@@ -107,7 +119,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
107 (!current_entry || (browser->use_navkeypressed && 119 (!current_entry || (browser->use_navkeypressed &&
108 !browser->navkeypressed))); 120 !browser->navkeypressed)));
109 int width = browser->width, printed; 121 int width = browser->width, printed;
110 int i, pcnt_width = 7 * ab->nr_events; 122 int i, pcnt_width = annotate_browser__pcnt_width(ab);
111 double percent_max = 0.0; 123 double percent_max = 0.0;
112 char bf[256]; 124 char bf[256];
113 125
@@ -117,19 +129,34 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
117 } 129 }
118 130
119 if (dl->offset != -1 && percent_max != 0.0) { 131 if (dl->offset != -1 && percent_max != 0.0) {
120 for (i = 0; i < ab->nr_events; i++) { 132 if (percent_max != 0.0) {
121 ui_browser__set_percent_color(browser, 133 for (i = 0; i < ab->nr_events; i++) {
122 bdl->samples[i].percent, 134 ui_browser__set_percent_color(browser,
123 current_entry); 135 bdl->samples[i].percent,
124 if (annotate_browser__opts.show_total_period) 136 current_entry);
125 slsmg_printf("%6" PRIu64 " ", 137 if (annotate_browser__opts.show_total_period)
126 bdl->samples[i].nr); 138 slsmg_printf("%6" PRIu64 " ",
127 else 139 bdl->samples[i].nr);
128 slsmg_printf("%6.2f ", bdl->samples[i].percent); 140 else
141 slsmg_printf("%6.2f ", bdl->samples[i].percent);
142 }
143 } else {
144 slsmg_write_nstring(" ", 7 * ab->nr_events);
129 } 145 }
130 } else { 146 } else {
131 ui_browser__set_percent_color(browser, 0, current_entry); 147 ui_browser__set_percent_color(browser, 0, current_entry);
132 slsmg_write_nstring(" ", pcnt_width); 148 slsmg_write_nstring(" ", 7 * ab->nr_events);
149 }
150 if (ab->have_cycles) {
151 if (dl->ipc)
152 slsmg_printf("%*.2f ", IPC_WIDTH - 1, dl->ipc);
153 else
154 slsmg_write_nstring(" ", IPC_WIDTH);
155 if (dl->cycles)
156 slsmg_printf("%*" PRIu64 " ",
157 CYCLES_WIDTH - 1, dl->cycles);
158 else
159 slsmg_write_nstring(" ", CYCLES_WIDTH);
133 } 160 }
134 161
135 SLsmg_write_char(' '); 162 SLsmg_write_char(' ');
@@ -232,7 +259,7 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
232 unsigned int from, to; 259 unsigned int from, to;
233 struct map_symbol *ms = ab->b.priv; 260 struct map_symbol *ms = ab->b.priv;
234 struct symbol *sym = ms->sym; 261 struct symbol *sym = ms->sym;
235 u8 pcnt_width = 7; 262 u8 pcnt_width = annotate_browser__pcnt_width(ab);
236 263
237 /* PLT symbols contain external offsets */ 264 /* PLT symbols contain external offsets */
238 if (strstr(sym->name, "@plt")) 265 if (strstr(sym->name, "@plt"))
@@ -256,8 +283,6 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
256 to = (u64)btarget->idx; 283 to = (u64)btarget->idx;
257 } 284 }
258 285
259 pcnt_width *= ab->nr_events;
260
261 ui_browser__set_color(browser, HE_COLORSET_CODE); 286 ui_browser__set_color(browser, HE_COLORSET_CODE);
262 __ui_browser__line_arrow(browser, pcnt_width + 2 + ab->addr_width, 287 __ui_browser__line_arrow(browser, pcnt_width + 2 + ab->addr_width,
263 from, to); 288 from, to);
@@ -267,9 +292,7 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser)
267{ 292{
268 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b); 293 struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
269 int ret = ui_browser__list_head_refresh(browser); 294 int ret = ui_browser__list_head_refresh(browser);
270 int pcnt_width; 295 int pcnt_width = annotate_browser__pcnt_width(ab);
271
272 pcnt_width = 7 * ab->nr_events;
273 296
274 if (annotate_browser__opts.jump_arrows) 297 if (annotate_browser__opts.jump_arrows)
275 annotate_browser__draw_current_jump(browser); 298 annotate_browser__draw_current_jump(browser);