Skip to content

perf stat: add interval counter printing

Stephane Eranian lkml 7 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest2 patches 2 repliesIn review
  2. v62 patches 10 repliesSuperseded
  3. v52 patches 0 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v42 patches4 repliesSuperseded
v32 patches2 repliesSuperseded
v22 patches5 repliesSuperseded
v12 patches2 repliesSuperseded

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2perf tools: add evsel prev_raw_count fieldtools/perf/util/evsel.c tools/perf/util/evsel.h+27 -01 reply
2/2perf stat: add interval printingtools/perf/Documentation/perf-stat.txt tools/perf/builtin-stat.c+146 -151 reply

Reviews trailers per patch

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

Read the v7 thread

Cover letter [PATCH v7 0/2] perf stat: add interval counter printing

This small patchset extends perf stat with the -I option.

The -I option enables interval printing. It expects an interval duration in milliseconds. Minimum is 100ms. Once, activated perf stat prints events deltas since last printout. All modes are supported.

$ perf stat -I 1000 -e cycles noploop 10
noploop for 10 seconds
 #           time             counts events
      1.000109853      2,388,560,546 cycles
      2.000262846      2,393,332,358 cycles
      3.000354131      2,393,176,537 cycles
      4.000439503      2,393,203,790 cycles
      5.000527075      2,393,167,675 cycles
      6.000609052      2,393,203,670 cycles
      7.000691082      2,393,175,678 cycles

The output format makes it easy to feed into a plotting program such as gnuplot when the -I option is used in combination with the -x option:

$ perf stat -x, -I 1000 -e cycles noploop 10
noploop for 10 seconds
1.000084113,2378775498,cycles
2.000245798,2391056897,cycles
3.000354445,2392089414,cycles
4.000459115,2390936603,cycles
5.000565341,2392108173,cycles

The first patch adds the code to keep previous counts. The second is the actual extension of perf stat.

In v2, we changed the option from -T to -I based on feedback from Andi Kleen (who is using -T in an upcoming patch).

In v3, added compute_deltas() to evsel.c to factorize deltas computation based on Jiri's comments.

In v4, we made sure that counts are printed in case the run is interrupted by CTRL-C based on Andi Kleen's feedback.

In v5, we added the column headings printed every 25 lines. Cleaned up the code some more based on Namhyung's comments.

In v6, we simplify print_stat() by dropping the useless check for interval as noted by Namhyung Kim. We also rebase to 3.8.0-rc4.

In v7, we simply rebased to Arnaldo's perf/core tree.

Stephane Eranian (2):
perf tools: add evsel prev_raw_count field
perf stat: add interval printing

 tools/perf/Documentation/perf-stat.txt |    4 +
 tools/perf/builtin-stat.c              |  157 +++++++++++++++++++++++++++++---
 tools/perf/util/evsel.c                |   26 ++++++
 tools/perf/util/evsel.h                |    1 +
 4 files changed, 173 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.10.4