Skip to content

perf tools: Add support for user defined metric

Jiri Olsa lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 13 repliesIn review
  2. v23 patches 6 repliesSuperseded
  3. v1 RFC3 patches 4 repliesSuperseded

Changes in v3 from the cover letter

- added doc for metrics file in perf stat man page
- reporting error line number now
- changed '#' style comment to C way with '//'

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4perf expr: Add parsing support for multiple expressionstools/perf/tests/expr.c tools/perf/util/expr.c tools/perf/util/expr.h +2 more+60 -32 replies
2/4perf expr: Allow comments in custom metric filetools/perf/util/expr.l+12 -00 replies
3/4perf stat: Add --metrics-file optiontools/perf/Documentation/perf-stat.txt tools/perf/builtin-stat.c tools/perf/util/metricgroup.c +2 more+147 -103 replies
4/4perf expr: Report line number with errortools/perf/tests/expr.c tools/perf/util/expr.h tools/perf/util/expr.l +2 more+24 -45 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCHv3 0/4] perf tools: Add support for user defined metric

hi,
Joe asked for possibility to add user defined metrics. Given that we already have metrics support, I added --metrics-file option that allows to specify custom metrics.

  $ cat metrics
  # IPC
  mine1 = instructions / cycles;
  /* DECODED_ICACHE_UOPS% */
  mine2 = 100 * (idq.dsb_uops / \ (idq.ms_uops + idq.mite_uops + idq.dsb_uops + lsd.uops));
  $ sudo perf stat --metrics-file ./metrics -M mine1,mine2 --metric-only -a -I 1000
  #           time       insn per cycle                mine1                mine2
       1.000536263                0.71                   0.7                 41.4
       2.002069025                0.31                   0.3                 14.1
       3.003427684                0.27                   0.3                 14.8
       4.004807132                0.25                   0.2                 12.1
  ...

v3 changes:
- added doc for metrics file in perf stat man page
- reporting error line number now
- changed '#' style comment to C way with '//'

v2 changes:
- add new --metrics-file option
- rebased on current perf/core expression bison/flex enhancements

Also available in:
git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
perf/metric

thanks,
jirka

---
Jiri Olsa (4):
perf expr: Add parsing support for multiple expressions perf expr: Allow comments in custom metric file perf stat: Add --metrics-file option
perf expr: Report line number with error

 tools/perf/Documentation/perf-stat.txt | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/builtin-stat.c              |  7 +++++--
 tools/perf/tests/expr.c                | 18 ++++++++++++++++++
 tools/perf/util/expr.c                 |  6 ++++++
 tools/perf/util/expr.h                 | 21 +++++++++++++++++++--
 tools/perf/util/expr.l                 | 34 ++++++++++++++++++++++++++++++++++
 tools/perf/util/expr.y                 | 21 +++++++++++++++++----
 tools/perf/util/metricgroup.c          | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 tools/perf/util/metricgroup.h          |  3 ++-
 tools/perf/util/stat.h                 |  1 +
 10 files changed, 242 insertions(+), 16 deletions(-)