From: Jiri Olsa <jolsa@redhat.com>
To: Jin Yao <yao.jin@linux.intel.com>
Cc: acme@kernel.org, jolsa@kernel.org, peterz@infradead.org,
mingo@redhat.com, alexander.shishkin@linux.intel.com,
Linux-kernel@vger.kernel.org, ak@linux.intel.com,
kan.liang@intel.com, yao.jin@intel.com
Subject: Re: [PATCH] perf stat: Align CSV output for summary mode
Date: Tue, 16 Mar 2021 14:07:09 +0100 [thread overview]
Message-ID: <YFCtfXlaKbIeEMwk@krava> (raw)
In-Reply-To: <20210316072900.1739-1-yao.jin@linux.intel.com>
On Tue, Mar 16, 2021 at 03:29:00PM +0800, Jin Yao wrote:
> perf-stat has supported the summary mode. But the summary
> lines break the CSV output so it's hard for scripts to parse
> the result.
>
> Before:
>
> # perf stat -x, -I1000 --interval-count 1 --summary
> 1.001323097,8013.48,msec,cpu-clock,8013483384,100.00,8.013,CPUs utilized
> 1.001323097,270,,context-switches,8013513297,100.00,0.034,K/sec
> 1.001323097,13,,cpu-migrations,8013530032,100.00,0.002,K/sec
> 1.001323097,184,,page-faults,8013546992,100.00,0.023,K/sec
> 1.001323097,20574191,,cycles,8013551506,100.00,0.003,GHz
> 1.001323097,10562267,,instructions,8013564958,100.00,0.51,insn per cycle
> 1.001323097,2019244,,branches,8013575673,100.00,0.252,M/sec
> 1.001323097,106152,,branch-misses,8013585776,100.00,5.26,of all branches
> 8013.48,msec,cpu-clock,8013483384,100.00,7.984,CPUs utilized
> 270,,context-switches,8013513297,100.00,0.034,K/sec
> 13,,cpu-migrations,8013530032,100.00,0.002,K/sec
> 184,,page-faults,8013546992,100.00,0.023,K/sec
> 20574191,,cycles,8013551506,100.00,0.003,GHz
> 10562267,,instructions,8013564958,100.00,0.51,insn per cycle
> 2019244,,branches,8013575673,100.00,0.252,M/sec
> 106152,,branch-misses,8013585776,100.00,5.26,of all branches
>
> The summary line loses the timestamp column, which breaks the
> CVS output.
>
> We add a column at the 'timestamp' position and it just says 'summary'
> for the summary line.
>
> After:
>
> # perf stat -x, -I1000 --interval-count 1 --summary
looks ok, but maybe make the option more related to CVS, like:
--x-summary, --cvs-summary ...?
jirka
> 1.001196053,8012.72,msec,cpu-clock,8012722903,100.00,8.013,CPUs utilized
> 1.001196053,218,,context-switches,8012753271,100.00,0.027,K/sec
> 1.001196053,9,,cpu-migrations,8012769767,100.00,0.001,K/sec
> 1.001196053,0,,page-faults,8012786257,100.00,0.000,K/sec
> 1.001196053,15004518,,cycles,8012790637,100.00,0.002,GHz
> 1.001196053,7954691,,instructions,8012804027,100.00,0.53,insn per cycle
> 1.001196053,1590259,,branches,8012814766,100.00,0.198,M/sec
> 1.001196053,82601,,branch-misses,8012824365,100.00,5.19,of all branches
> summary,8012.72,msec,cpu-clock,8012722903,100.00,7.986,CPUs utilized
> summary,218,,context-switches,8012753271,100.00,0.027,K/sec
> summary,9,,cpu-migrations,8012769767,100.00,0.001,K/sec
> summary,0,,page-faults,8012786257,100.00,0.000,K/sec
> summary,15004518,,cycles,8012790637,100.00,0.002,GHz
> summary,7954691,,instructions,8012804027,100.00,0.53,insn per cycle
> summary,1590259,,branches,8012814766,100.00,0.198,M/sec
> summary,82601,,branch-misses,8012824365,100.00,5.19,of all branches
>
> Now it's easy for script to analyse the summary lines.
>
> Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
> ---
> tools/perf/util/stat-display.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index 7f09cdaf5b60..c4183d3e87a4 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -439,6 +439,10 @@ static void printout(struct perf_stat_config *config, struct aggr_cpu_id id, int
> if (counter->cgrp)
> os.nfields++;
> }
> +
> + if (config->csv_output && config->summary && !config->interval)
> + fprintf(config->output, "%16s%s", "summary", config->csv_sep);
> +
> if (run == 0 || ena == 0 || counter->counts->scaled == -1) {
> if (config->metric_only) {
> pm(config, &os, NULL, "", "", 0);
> --
> 2.17.1
>
next prev parent reply other threads:[~2021-03-16 13:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-16 7:29 [PATCH] perf stat: Align CSV output for summary mode Jin Yao
2021-03-16 13:07 ` Jiri Olsa [this message]
2021-03-16 13:07 ` Jiri Olsa
2021-03-16 16:34 ` Andi Kleen
2021-03-16 19:05 ` Arnaldo Carvalho de Melo
2021-03-16 20:02 ` Andi Kleen
2021-03-16 21:55 ` Jiri Olsa
2021-03-17 0:51 ` Jin, Yao
2021-03-17 1:30 ` Andi Kleen
2021-03-17 1:39 ` Jin, Yao
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=YFCtfXlaKbIeEMwk@krava \
--to=jolsa@redhat.com \
--cc=Linux-kernel@vger.kernel.org \
--cc=acme@kernel.org \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@intel.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=yao.jin@intel.com \
--cc=yao.jin@linux.intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.