linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	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>
Subject: Re: [PATCH 07/12] perf diff: Add ratio computation way to compare hist entries
Date: Fri, 07 Sep 2012 14:45:28 +0900	[thread overview]
Message-ID: <871uiecrnr.fsf@sejong.aot.lge.com> (raw)
In-Reply-To: <1346946426-13496-8-git-send-email-jolsa@redhat.com> (Jiri Olsa's message of "Thu, 6 Sep 2012 17:47:01 +0200")

On Thu,  6 Sep 2012 17:47:01 +0200, Jiri Olsa wrote:
> Adding -c option to select computation method with the current
> 'Delta' computation as default. Current posible values are of
> this option are: 'delta' and 'ratio'.
>
> Adding 'ratio' as new computation way to compare hist entries.
> If specified the 'Ratio' column is displayed with value 'r'
> computed as:
>
>   r = A->period / B->period
>
> with:
>   - A/B being matching hist entry from first/second file specified
>     (or perf.data/perf.data.old) respectively.
>   - period being the hist entry period value
>
> 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 | 33 ++++++++++++++++++++++
>  tools/perf/builtin-diff.c              | 51 +++++++++++++++++++++++++++++++++-
>  tools/perf/ui/stdio/hist.c             | 13 +++++++++
>  tools/perf/util/hist.h                 |  1 +
>  4 files changed, 97 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt
> index 6ce9585..8fff061 100644
> --- a/tools/perf/Documentation/perf-diff.txt
> +++ b/tools/perf/Documentation/perf-diff.txt
> @@ -76,6 +76,39 @@ OPTIONS
>  --baseline-only::
>          Show only items with match in baseline.
>  
> +-c::
> +--compute::
> +        Differential computation selection - delta,ratio (default is delta).
> +        See COMPARISON METHODS section for more info.
> +
> +COMPARISON METHODS
> +------------------
> +delta
> +~~~~~
> +If specified the 'Delta' column is displayed with value 'd' computed as:
> +
> +  d = A->period_percent - B->period_percent
> +
> +with:
> +  - A/B being matching hist entry from first/second file specified
> +    (or perf.data/perf.data.old) respectively.
> +
> +  - period_percent being the % of the hist entry period value within
> +    single data file
> +
> +ratio
> +~~~~~
> +If specified the 'Ratio' column is displayed with value 'r' computed as:
> +
> +  r = A->period / B->period
> +
> +with:
> +  - A/B being matching hist entry from first/second file specified
> +    (or perf.data/perf.data.old) respectively.
> +
> +  - period being the hist entry period value
> +
> +
>  SEE ALSO
>  --------
>  linkperf:perf-record[1]
> diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
> index 46f4a10..cde08d4 100644
> --- a/tools/perf/builtin-diff.c
> +++ b/tools/perf/builtin-diff.c
> @@ -27,6 +27,39 @@ static bool  force;
>  static bool show_displacement;
>  static bool show_baseline_only;
>  
> +enum {
> +	COMPUTE_DELTA,
> +	COMPUTE_RATIO,
> +	COMPUTE_MAX,
> +};
> +
> +const char *compute_names[COMPUTE_MAX] = {
> +	[COMPUTE_DELTA] = "delta",
> +	[COMPUTE_RATIO] = "ratio",
> +};
> +
> +static const char *compute_str;
> +static int compute;
> +
> +static int setup_compute(void)
> +{
> +	unsigned i;
> +
> +	if (!compute_str) {
> +		compute = COMPUTE_DELTA;
> +		return 0;
> +	}
> +
> +	for (i = 0; i < COMPUTE_MAX; i++)
> +		if (!strcmp(compute_str, compute_names[i])) {
> +			compute = i;
> +			return 0;
> +		}
> +
> +	pr_err("Failed to find valid compute string\n");
> +	return -EINVAL;
> +}
> +
>  static int hists__add_entry(struct hists *self,
>  			    struct addr_location *al, u64 period)
>  {
> @@ -263,6 +296,8 @@ static const struct option options[] = {
>  		    "Show position displacement relative to baseline"),
>  	OPT_BOOLEAN('b', "baseline-only", &show_baseline_only,
>  		    "Show only items with match in baseline"),
> +	OPT_STRING('c', "compute", &compute_str, "delta,ratio (default delta)",
> +		   "Entries differential computation selection"),

Why not make it OPT_CALLBACK?

Thanks,
Namhyung


>  	OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
>  		    "dump raw trace in ASCII"),
>  	OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
> @@ -288,7 +323,18 @@ static void setup_ui_stdio(void)
>  {
>  	hists_stdio_column__register_idx(HISTC_BASELINE);
>  	hists_stdio_column__register_global();
> -	hists_stdio_column__register_idx(HISTC_DELTA);
> +
> +	switch (compute) {
> +	case COMPUTE_DELTA:
> +		hists_stdio_column__register_idx(HISTC_DELTA);
> +		break;
> +	case COMPUTE_RATIO:
> +		hists_stdio_column__register_idx(HISTC_RATIO);
> +		break;
> +	default:
> +		BUG_ON(1);
> +	};
> +
>  	if (show_displacement)
>  		hists_stdio_column__register_idx(HISTC_DISPLACEMENT);
>  }
> @@ -315,6 +361,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix __used)
>  	if (symbol__init() < 0)
>  		return -1;
>  
> +	if (setup_compute())
> +		usage_with_options(diff_usage, options);
> +
>  	setup_sorting(diff_usage, options);
>  	setup_ui_stdio();
>  	setup_pager();
> diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
> index 48fb0b3..02ba1c7 100644
> --- a/tools/perf/ui/stdio/hist.c
> +++ b/tools/perf/ui/stdio/hist.c
> @@ -31,6 +31,18 @@ hists_stdio_column__delta_snprintf(struct hist_entry *he, char *bf,
>  }
>  
>  static int
> +hists_stdio_column__ratio_snprintf(struct hist_entry *he, char *bf,
> +				   size_t size, unsigned int width __used)
> +{
> +	struct hist_entry *pair = he->pair;
> +	double new_period = he->period;
> +	double old_period = pair ? pair->period : 0;
> +	double ratio = pair ? new_period / old_period : 0;
> +
> +	return percent_color_snprintf(bf, size, "%14.3F", ratio);
> +}
> +
> +static int
>  hists_stdio_column__baseline_snprintf(struct hist_entry *he, char *bf,
>  				      size_t size, unsigned int width __used)
>  {
> @@ -124,6 +136,7 @@ DEF_COLUMN(cpu_guest_us, HISTC_CPU_UTILIZATION_GUEST_US, 8, "guest us")
>  DEF_COLUMN(nr_samples, HISTC_NR_SAMPLES, 12, "Samples")
>  DEF_COLUMN(total_period, HISTC_TOTAL_PERIOD, 12, "Period")
>  DEF_COLUMN(delta, HISTC_DELTA, 8, "Delta")
> +DEF_COLUMN(ratio, HISTC_RATIO, 14, "Ratio")
>  DEF_COLUMN(displacement, HISTC_DISPLACEMENT, 5, "Displ")
>  };
>  
> diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
> index 36ff4c5..b24341d 100644
> --- a/tools/perf/util/hist.h
> +++ b/tools/perf/util/hist.h
> @@ -46,6 +46,7 @@ enum hist_column {
>  	HISTC_NR_SAMPLES,
>  	HISTC_TOTAL_PERIOD,
>  	HISTC_DELTA,
> +	HISTC_RATIO,
>  	HISTC_DISPLACEMENT,
>  
>  	/* sorted (hist_entry__sort_list) */

  reply	other threads:[~2012-09-07  5:52 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 [this message]
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 ` [PATCH 12/12] perf diff: Add -F option for ratio computation Jiri Olsa
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=871uiecrnr.fsf@sejong.aot.lge.com \
    --to=namhyung@kernel.org \
    --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=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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).