Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932698AbdGSVhL (ORCPT ); Wed, 19 Jul 2017 17:37:11 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34649 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753955AbdGSVhI (ORCPT ); Wed, 19 Jul 2017 17:37:08 -0400 From: Taeung Song To: Arnaldo Carvalho de Melo Cc: linux-kernel@vger.kernel.org, Namhyung Kim , Milian Wolff , Jiri Olsa Subject: [PATCH v3 5/9] perf anntoate browser: Fix the toggle total period view to show period, not number of samples Date: Thu, 20 Jul 2017 06:37:03 +0900 Message-Id: <1500500223-16753-1-git-send-email-treeze.taeung@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2765 Lines: 87 Currently the toggle total period view on the annotate TUI shows the number of samples, not period like below. So fix the toggle total period view on the annotate TUI like below. $ perf annotate --show-total-period Before: │ Disassembly of section .text: │ │ 0000000000109a90 <_mcount@@GLIBC_2.2.5>: │ sub $0x38,%rsp 3 │ mov %rax,(%rsp) 3 │ mov %rcx,0x8(%rsp) After: │ Disassembly of section .text: │ │ 0000000000109a90 <_mcount@@GLIBC_2.2.5>: │ sub $0x38,%rsp 2204022 │ mov %rax,(%rsp) 2207405 │ mov %rcx,0x8(%rsp) Reported-by: Namhyung Kim Cc: Milian Wolff Cc: Jiri Olsa Signed-off-by: Taeung Song --- tools/perf/ui/browsers/annotate.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 0be6bee..5ff1799 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -17,7 +17,7 @@ struct disasm_line_samples { double percent; - u64 nr; + struct sym_hist_entry sample; }; #define IPC_WIDTH 6 @@ -113,6 +113,10 @@ static int annotate_browser__pcnt_width(struct annotate_browser *ab) if (ab->have_cycles) w += IPC_WIDTH + CYCLES_WIDTH; + + if (annotate_browser__opts.show_total_period) + w += 4 * ab->nr_events; + return w; } @@ -150,8 +154,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int bdl->samples[i].percent, current_entry); if (annotate_browser__opts.show_total_period) { - ui_browser__printf(browser, "%6" PRIu64 " ", - bdl->samples[i].nr); + ui_browser__printf(browser, "%10" PRIu64 " ", + bdl->samples[i].sample.period); } else { ui_browser__printf(browser, "%6.2f ", bdl->samples[i].percent); @@ -161,7 +165,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int ui_browser__set_percent_color(browser, 0, current_entry); if (!show_title) - ui_browser__write_nstring(browser, " ", 7 * ab->nr_events); + ui_browser__write_nstring(browser, " ", pcnt_width); else ui_browser__printf(browser, "%*s", 7, "Percent"); } @@ -456,7 +460,7 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, pos->offset, next ? next->offset : len, &path, &sample); - bpos->samples[i].nr = sample.nr_samples; + bpos->samples[i].sample = sample; if (max_percent < bpos->samples[i].percent) max_percent = bpos->samples[i].percent; -- 2.7.4