Re: [PATCH 6/7] perf, tools, stat: Add --metric-only support for -A

From: Jiri Olsa
Date: Thu Mar 03 2016 - 06:34:30 EST


On Wed, Mar 02, 2016 at 04:24:57PM -0800, Andi Kleen wrote:
> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> Add metric only support for -A too. This requires a new print
> function that prints the metrics in the right order.
>
> v2: Fix manpage
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
> ---
> tools/perf/Documentation/perf-stat.txt | 2 +-
> tools/perf/builtin-stat.c | 48 ++++++++++++++++++++++++++++------
> 2 files changed, 41 insertions(+), 9 deletions(-)
>
> diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
> index 271f71d..341757a 100644
> --- a/tools/perf/Documentation/perf-stat.txt
> +++ b/tools/perf/Documentation/perf-stat.txt
> @@ -141,7 +141,7 @@ The overhead percentage could be high in some cases, for instance with small, su
>
> --metric-only::
> Only print computed metrics. Print them in a single line.
> -Don't show any raw values. Not supported with -A or --per-thread.
> +Don't show any raw values. Not supported with --per-thread.
>
> --per-socket::
> Aggregate counts per processor socket for system-wide mode measurements. This
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 0196fed..42975ae 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -1250,10 +1250,43 @@ static void print_counter(struct perf_evsel *counter, char *prefix)
> }
> }
>
> +static void print_no_aggr_metric(char *prefix)
> +{
> + int cpu;
> + int nrcpus = 0;
> + struct perf_evsel *counter;
> + u64 ena, run, val;
> + double uval;
> +
> + evlist__for_each(evsel_list, counter) {
> + nrcpus = perf_evsel__nr_cpus(counter);
> + break;
> + }

what's the loop for? why can't you use evsel_list->cpus ?

jirka