Re: [RFC 0/3] perf tools: Add support for used defined metric

From: Jiri Olsa
Date: Thu Dec 12 2019 - 04:37:18 EST


On Wed, Dec 11, 2019 at 03:01:26PM -0800, Andi Kleen wrote:
> On Wed, Dec 11, 2019 at 11:47:57PM +0100, Jiri Olsa wrote:
> > hi,
> > Joe asked for possibility to add user defined metrics. Given that
> > we already have metrics support, I added --metric option that allows
> > to specify metric on the command line, like:
> >
> > # perf stat --metric 'DECODED_ICACHE_UOPS% = 100 * (idq.dsb_uops / \
> > (idq.ms_uops + idq.mite_uops + idq.dsb_uops + lsd.uops))' ...
> >
> > The code facilitates the current metric code, and I was surprised
> > how easy it was, so I'm not sure I omitted something ;-)
>
> There are some asserts you can hit, like for too many events.
>
> Also some of the syntax (e.g. using @ instead of / and escapes) are
> not super user friendly.
>
> Other than that it should be ok.
>
> Of course it would be better to put it into a file,
> and then support comments etc.

should be also reasonable easy, redirecting the input for lex

>
> I've been considering some extensions to perf to support @file
> reading with comment support.
>
> Right now there are some very odd bugs when you do that, lie
>
> -e 'event,<newline>
> event,<newline>
> event...'
>
> adds the newline to the event name, which breaks the output formats.

should be possible to ignore new lines at some point no?

jirka