linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
	Corey Ashford <cjashfor@linux.vnet.ibm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Andi Kleen <andi@firstfloor.org>, David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@redhat.com>
Subject: [PATCH 12/12] perf diff: Add -F option for ratio computation
Date: Thu,  6 Sep 2012 17:47:06 +0200	[thread overview]
Message-ID: <1346946426-13496-13-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1346946426-13496-1-git-send-email-jolsa@redhat.com>

The -F option displays the formula for specified computation.
Adding this support for weighted diff computation.

Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
---
 tools/perf/Documentation/perf-diff.txt |  2 +-
 tools/perf/builtin-diff.c              | 19 +++++++++++++++++++
 tools/perf/ui/stdio/hist.c             |  8 ++++++++
 tools/perf/ui/stdio/hist.h             |  1 +
 tools/perf/util/hist.h                 |  1 +
 5 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
index 4d65407..1d416a5 100644
--- a/tools/perf/Documentation/perf-diff.txt
+++ b/tools/perf/Documentation/perf-diff.txt
@@ -89,7 +89,7 @@ OPTIONS
 
 -F::
 --formula::
-        Show formula for given computation (supported: wdiff)
+        Show formula for given computation (supported: wdiff,ratio)
 
 COMPARISON METHODS
 ------------------
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 9125eee..62ceda3 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -158,6 +158,22 @@ double perf_diff__compute_ratio(struct hist_entry *he)
 	return he->diff.period_ratio;
 }
 
+int perf_diff__formula_ratio(struct hist_entry *he, char *bf, size_t size)
+{
+	struct hist_entry *pair = he->pair;
+	double new_period = he->period;
+	double old_period = pair ? pair->period : 0;
+	char formula[100];
+
+	if (pair)
+		scnprintf(formula, 100, "%.0F / %.0F",
+			  new_period, old_period);
+	else
+		*formula = 0x0;
+
+	return scnprintf(bf, size, "%-50s", formula);
+}
+
 double perf_diff__compute_wdiff(struct hist_entry *he)
 {
 	struct hist_entry *pair = he->pair;
@@ -594,6 +610,9 @@ static void setup_ui_stdio(void)
 		case COMPUTE_WEIGHTED_DIFF:
 			hists_stdio_column__register_idx(HISTC_FORMULA_WEIGHTED_DIFF);
 			break;
+		case COMPUTE_RATIO:
+			hists_stdio_column__register_idx(HISTC_FORMULA_RATIO);
+			break;
 		default:
 			break;
 	};
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 8cf4ebd..c7ca7ed 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -157,6 +157,13 @@ hists_stdio_column__formula_wdiff_snprintf(struct hist_entry *he, char *bf,
 	return perf_diff__formula_wdiff(he, bf, size);
 }
 
+static int
+hists_stdio_column__formula_ratio_snprintf(struct hist_entry *he, char *bf,
+					   size_t size, unsigned int width __used)
+{
+	return perf_diff__formula_ratio(he, bf, size);
+}
+
 LIST_HEAD(hists_stdio_column__list);
 
 #define DEF_COLUMN(name, c, w, h)					\
@@ -182,6 +189,7 @@ DEF_COLUMN(delta, HISTC_DELTA, 8, "Delta")
 DEF_COLUMN(ratio, HISTC_RATIO, 14, "Ratio")
 DEF_COLUMN(wdiff, HISTC_WEIGHTED_DIFF, 13, "Weighted diff")
 DEF_COLUMN(displacement, HISTC_DISPLACEMENT, 5, "Displ")
+DEF_COLUMN(formula_ratio, HISTC_FORMULA_RATIO, 50, "Formula")
 DEF_COLUMN(formula_wdiff, HISTC_FORMULA_WEIGHTED_DIFF, 50, "Formula")
 };
 
diff --git a/tools/perf/ui/stdio/hist.h b/tools/perf/ui/stdio/hist.h
index 4f62224..dba1e64 100644
--- a/tools/perf/ui/stdio/hist.h
+++ b/tools/perf/ui/stdio/hist.h
@@ -21,5 +21,6 @@ double perf_diff__compute_delta(struct hist_entry *he);
 double perf_diff__compute_ratio(struct hist_entry *he);
 double perf_diff__compute_wdiff(struct hist_entry *he);
 
+int perf_diff__formula_ratio(struct hist_entry *he, char *bf, size_t size);
 int perf_diff__formula_wdiff(struct hist_entry *he, char *bf, size_t size);
 #endif /* __PERF_UI_STDIO_HIST_H */
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index e1511cc..faa77ce 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -50,6 +50,7 @@ enum hist_column {
 	HISTC_RATIO,
 	HISTC_WEIGHTED_DIFF,
 	HISTC_DISPLACEMENT,
+	HISTC_FORMULA_RATIO,
 	HISTC_FORMULA_WEIGHTED_DIFF,
 
 	/* sorted (hist_entry__sort_list) */
-- 
1.7.11.4


  parent reply	other threads:[~2012-09-06 15:48 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-06 15:46 [RFC 00/12] perf diff: Factor diff command Jiri Olsa
2012-09-06 15:46 ` [PATCH 01/12] perf diff: Make diff command work with evsel hists Jiri Olsa
2012-09-08 11:41   ` [tip:perf/core] " tip-bot for Jiri Olsa
2012-09-06 15:46 ` [PATCH 02/12] perf tools: Replace sort's standalone field_sep with symbol_conf.field_sep Jiri Olsa
2012-09-08 11:42   ` [tip:perf/core] perf tools: Replace sort' s " tip-bot for Jiri Olsa
2012-09-06 15:46 ` [PATCH 03/12] perf hists: Add struct hists pointer to struct hist_entry Jiri Olsa
2012-09-06 15:46 ` [PATCH 04/12] perf diff: Refactor diff displacement possition info Jiri Olsa
2012-09-08  0:56   ` Arnaldo Carvalho de Melo
2012-09-06 15:46 ` [PATCH 05/12] perf diff: Refactor stdio ui data columns output Jiri Olsa
2012-09-07  2:55   ` Namhyung Kim
2012-09-07  9:20     ` Jiri Olsa
2012-09-08 12:35     ` Jiri Olsa
2012-09-08 12:50       ` Arnaldo Carvalho de Melo
2012-09-08 14:37         ` Namhyung Kim
2012-09-08 15:10           ` Arnaldo Carvalho de Melo
2012-09-08 15:12           ` Arnaldo Carvalho de Melo
2012-09-08 15:21             ` Arnaldo Carvalho de Melo
2012-09-06 15:47 ` [PATCH 06/12] perf diff: Add -b option for perf diff to display paired entries only Jiri Olsa
2012-09-06 15:47 ` [PATCH 07/12] perf diff: Add ratio computation way to compare hist entries Jiri Olsa
2012-09-07  5:45   ` Namhyung Kim
2012-09-07  9:26     ` Jiri Olsa
2012-09-07 15:33     ` Arnaldo Carvalho de Melo
2012-09-07 15:41       ` Namhyung Kim
2012-09-06 15:47 ` [PATCH 08/12] perf diff: Add option to sort entries based on diff computation Jiri Olsa
2012-09-06 15:47 ` [PATCH 09/12] perf diff: Add weighted diff computation way to compare hist entries Jiri Olsa
2012-09-07  5:58   ` Namhyung Kim
2012-09-07  9:28     ` Jiri Olsa
2012-09-07 13:33       ` Namhyung Kim
2012-09-07 15:26         ` Peter Zijlstra
2012-09-07 15:31         ` Arnaldo Carvalho de Melo
2012-09-07 16:08           ` Peter Zijlstra
2012-09-06 15:47 ` [PATCH 10/12] perf diff: Add -p option to display period values for " Jiri Olsa
2012-09-06 15:47 ` [PATCH 11/12] perf diff: Add -F option to display formula for computation Jiri Olsa
2012-09-07  6:02   ` Namhyung Kim
2012-09-07  9:30     ` Jiri Olsa
2012-09-06 15:47 ` Jiri Olsa [this message]
2012-09-06 17:31 ` [RFC 00/12] perf diff: Factor diff command Jiri Olsa
2012-09-06 18:41 ` Peter Zijlstra
2012-09-06 21:25   ` Paul E. McKenney
2012-09-07  7:05     ` Peter Zijlstra

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=1346946426-13496-13-git-send-email-jolsa@redhat.com \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=andi@firstfloor.org \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=dsahern@gmail.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung@kernel.org \
    --cc=paulmck@linux.vnet.ibm.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).