linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Arun Sharma <asharma@fb.com>, David Ahern <dsahern@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung.kim@lge.com>
Subject: [PATCH 12/15] perf ui/hist: Add support to accumulated hist stat
Date: Thu, 13 Sep 2012 16:20:08 +0900	[thread overview]
Message-ID: <1347520811-28150-13-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1347520811-28150-1-git-send-email-namhyung@kernel.org>

From: Namhyung Kim <namhyung.kim@lge.com>

Print accumulated stat of a hist entry if requested.

Cc: Arun Sharma <asharma@fb.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/hist.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index d6ddeb10e678..7bf2999d2d17 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -22,6 +22,9 @@ static int hpp__color_overhead(struct perf_hpp *hpp, struct hist_entry *he)
 {
 	double percent = 100.0 * he->stat.period / hpp->total_period;
 
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period / hpp->total_period;
+
 	if (hpp->ptr) {
 		struct hists *old_hists = hpp->ptr;
 		u64 total_period = old_hists->stats.total_period;
@@ -41,6 +44,9 @@ static int hpp__entry_overhead(struct perf_hpp *hpp, struct hist_entry *he)
 	double percent = 100.0 * he->stat.period / hpp->total_period;
 	const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%";
 
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period / hpp->total_period;
+
 	if (hpp->ptr) {
 		struct hists *old_hists = hpp->ptr;
 		u64 total_period = old_hists->stats.total_period;
@@ -70,6 +76,10 @@ static int hpp__width_overhead_sys(struct perf_hpp *hpp __maybe_unused)
 static int hpp__color_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he)
 {
 	double percent = 100.0 * he->stat.period_sys / hpp->total_period;
+
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period_sys / hpp->total_period;
+
 	return percent_color_snprintf(hpp->buf, hpp->size, "%6.2f%%", percent);
 }
 
@@ -78,6 +88,9 @@ static int hpp__entry_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he)
 	double percent = 100.0 * he->stat.period_sys / hpp->total_period;
 	const char *fmt = symbol_conf.field_sep ? "%.2f" : "%6.2f%%";
 
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period_sys / hpp->total_period;
+
 	return scnprintf(hpp->buf, hpp->size, fmt, percent);
 }
 
@@ -96,6 +109,10 @@ static int hpp__width_overhead_us(struct perf_hpp *hpp __maybe_unused)
 static int hpp__color_overhead_us(struct perf_hpp *hpp, struct hist_entry *he)
 {
 	double percent = 100.0 * he->stat.period_us / hpp->total_period;
+
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period_us / hpp->total_period;
+
 	return percent_color_snprintf(hpp->buf, hpp->size, "%6.2f%%", percent);
 }
 
@@ -104,6 +121,9 @@ static int hpp__entry_overhead_us(struct perf_hpp *hpp, struct hist_entry *he)
 	double percent = 100.0 * he->stat.period_us / hpp->total_period;
 	const char *fmt = symbol_conf.field_sep ? "%.2f" : "%6.2f%%";
 
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period_us / hpp->total_period;
+
 	return scnprintf(hpp->buf, hpp->size, fmt, percent);
 }
 
@@ -121,6 +141,10 @@ static int hpp__color_overhead_guest_sys(struct perf_hpp *hpp,
 					 struct hist_entry *he)
 {
 	double percent = 100.0 * he->stat.period_guest_sys / hpp->total_period;
+
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period_guest_sys / hpp->total_period;
+
 	return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%% ", percent);
 }
 
@@ -130,6 +154,9 @@ static int hpp__entry_overhead_guest_sys(struct perf_hpp *hpp,
 	double percent = 100.0 * he->stat.period_guest_sys / hpp->total_period;
 	const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%% ";
 
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period_guest_sys / hpp->total_period;
+
 	return scnprintf(hpp->buf, hpp->size, fmt, percent);
 }
 
@@ -147,6 +174,10 @@ static int hpp__color_overhead_guest_us(struct perf_hpp *hpp,
 					struct hist_entry *he)
 {
 	double percent = 100.0 * he->stat.period_guest_us / hpp->total_period;
+
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period_guest_us / hpp->total_period;
+
 	return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%% ", percent);
 }
 
@@ -156,6 +187,9 @@ static int hpp__entry_overhead_guest_us(struct perf_hpp *hpp,
 	double percent = 100.0 * he->stat.period_guest_us / hpp->total_period;
 	const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%% ";
 
+	if (symbol_conf.cumulate_callchain)
+		percent = 100.0 * he->stat_acc->period_guest_us / hpp->total_period;
+
 	return scnprintf(hpp->buf, hpp->size, fmt, percent);
 }
 
@@ -174,8 +208,12 @@ static int hpp__width_samples(struct perf_hpp *hpp __maybe_unused)
 static int hpp__entry_samples(struct perf_hpp *hpp, struct hist_entry *he)
 {
 	const char *fmt = symbol_conf.field_sep ? "%" PRIu64 : "%11" PRIu64;
+	u64 samples = he->stat.nr_events;
 
-	return scnprintf(hpp->buf, hpp->size, fmt, he->stat.nr_events);
+	if (symbol_conf.cumulate_callchain)
+		samples = he->stat_acc->nr_events;
+
+	return scnprintf(hpp->buf, hpp->size, fmt, samples);
 }
 
 static int hpp__header_period(struct perf_hpp *hpp)
@@ -193,8 +231,12 @@ static int hpp__width_period(struct perf_hpp *hpp __maybe_unused)
 static int hpp__entry_period(struct perf_hpp *hpp, struct hist_entry *he)
 {
 	const char *fmt = symbol_conf.field_sep ? "%" PRIu64 : "%12" PRIu64;
+	u64 period = he->stat.period;
+
+	if (symbol_conf.cumulate_callchain)
+		period = he->stat_acc->period;
 
-	return scnprintf(hpp->buf, hpp->size, fmt, he->stat.period);
+	return scnprintf(hpp->buf, hpp->size, fmt, period);
 }
 
 static int hpp__header_delta(struct perf_hpp *hpp)
-- 
1.7.11.4


  parent reply	other threads:[~2012-09-13  7:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13  7:19 [RFC/PATCHSET 00/15] perf report: Add support to accumulate hist periods Namhyung Kim
2012-09-13  7:19 ` [PATCH 01/15] perf hists: Add missing period_* fields when collapsing a hist entry Namhyung Kim
2012-09-13  7:19 ` [PATCH 02/15] perf hists: Introduce struct he_stat Namhyung Kim
2012-09-13  7:19 ` [PATCH 03/15] perf hists: Move he->stat.nr_events initialization to a template Namhyung Kim
2012-09-13  7:20 ` [PATCH 04/15] perf hists: Convert hist entry functions to use struct he_stat Namhyung Kim
2012-09-13  7:20 ` [PATCH 05/15] perf hists: Add more helpers for hist entry stat Namhyung Kim
2012-09-13  7:20 ` [PATCH 06/15] perf hists: Add support for accumulated stat of hist entry Namhyung Kim
2012-09-13  7:20 ` [PATCH 07/15] perf hists: Check if accumulated when adding a " Namhyung Kim
2012-09-13  7:20 ` [PATCH 08/15] perf callchain: Add a couple of callchain helpers Namhyung Kim
2012-09-13  7:20 ` [PATCH 09/15] perf hists: Let add_hist_entry to make a hist entry template Namhyung Kim
2012-09-13  7:20 ` [PATCH 10/15] perf hists: Accumulate hist entry stat based on the callchain Namhyung Kim
2012-09-13  7:20 ` [PATCH 11/15] perf hists: Sort hist entries by accumulated period Namhyung Kim
2012-09-13  7:20 ` Namhyung Kim [this message]
2012-09-13  7:20 ` [PATCH 13/15] perf ui/browser: Add support to accumulated hist stat Namhyung Kim
2012-09-13  7:20 ` [PATCH 14/15] perf ui/gtk: " Namhyung Kim
2012-09-13  7:20 ` [PATCH 15/15] perf report: Add --cumulate option Namhyung Kim
2012-09-20 17:33 ` [RFC/PATCHSET 00/15] perf report: Add support to accumulate hist periods Arun Sharma
2012-09-25  4:57 ` Namhyung Kim
2012-09-27 23:01   ` Frederic Weisbecker
2012-09-28  5:49     ` Namhyung Kim
2012-09-28  7:07       ` Stephane Eranian
2012-09-28 15:14         ` Frederic Weisbecker
2012-09-28 16:36           ` Stephane Eranian
2012-09-28 15:27       ` Frederic Weisbecker
2012-10-29 19:08 ` Peter Zijlstra
2012-10-29 21:36   ` Arun Sharma
2012-10-30  6:59     ` Namhyung Kim
2012-10-30  8:17       ` Peter Zijlstra
2012-10-30  9:01         ` Ingo Molnar
2012-10-31  7:24           ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1347520811-28150-13-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=asharma@fb.com \
    --cc=dsahern@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).