Re: [PATCH] perf stat: Align CSV output for summary mode

From: Jiri Olsa
Date: Tue Mar 16 2021 - 09:08:48 EST


On Tue, Mar 16, 2021 at 02:07:12PM +0100, Jiri Olsa wrote:
> 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 ...?
>

and we'll need man page update for that

jirka