perf, tools, stat: Implement --metric-only mode
PATCH 1/1 perf, tools, stat: Implement --metric-only mode
From: Andi Kleen <[email protected]>
Add a new mode to only print metrics. Sometimes we don't care about the raw values, just want the computed metrics. This allows more compact printing, so with -I each sample is only a single line. This also allows easier plotting and processing with other tools.
The main target is with using --topdown, but it also works with -T and standard perf stat. A few metrics are not supported.
To avoiding having to hardcode all the metrics in the code it uses a two pass approach: first compute dummy metrics and only print the headers in the print_metric callback. Then use the callback to print the actual values. There are some additional changes in the stat printout code to handle all metrics being on a single line.
Example:
% perf stat -a -I 1000 --metric-only
1.000604977 frontend cycles idle backend cycles idle insn per cycle stalled cycles per insn branch-misses of all branches
1.000604977 0.76 2.35%
2.000924680 0.72 2.34%
3.001139592 0.76 2.57%
4.001358452 0.73 2.44%The output is fairly wide, but that's a trade off for the concise format.
--- tools/perf/Documentation/perf-stat.txt | 4 + tools/perf/builtin-stat.c | 201 +++++++++++++++++++++++++++++++-- 2 files changed, 196 insertions(+), 9 deletions(-)
tools/perf/Documentation/perf-stat.txt +4 -0
@@ -132,6 +132,10 @@ Print count deltas every N milliseconds (minimum: 10ms) The overhead percentage could be high in some cases, for instance with small, sub 100ms intervals. Use with caution. example: 'perf stat -I 1000 -e cycles -a sleep 5' +--metric-only:: +Only print computed metrics. Print them in a single line. +Don't show any raw values. Not supported with -A or --per-thread. + --per-socket:: Aggregate counts per processor socket for system-wide mode measurements. This is a useful mode to detect imbalance between sockets. To enable this mode,
tools/perf/builtin-stat.c +192 -9
308 lines not on this page · raw message
Signature · 1 line
2.4.3
Here's a v2 that fixes a problem in --per-core mode.
---
Add a new mode to only print metrics. Sometimes we don't care about the raw values, just want the computed metrics. This allows more compact printing, so with -I each sample is only a single line. This also allows easier plotting and processing with other tools.
The main target is with using --topdown, but it also works with -T and standard perf stat. A few metrics are not supported.
To avoiding having to hardcode all the metrics in the code it uses a two pass approach: first compute dummy metrics and only print the headers in the print_metric callback. Then use the callback to print the actual values. There are some additional changes in the stat printout code to handle all metrics being on a single line.
Example:
% perf stat -a -I 1000 --metric-only
1.000604977 frontend cycles idle backend cycles idle insn per cycle stalled cycles per insn branch-misses of all branches
1.000604977 0.76 2.35%
2.000924680 0.72 2.34%
3.001139592 0.76 2.57%
4.001358452 0.73 2.44%The output is fairly wide, but that's a trade off for the concise format.
v2: Fix --per-socket/core extra prefix printing.
--- tools/perf/Documentation/perf-stat.txt | 4 + tools/perf/builtin-stat.c | 201 +++++++++++++++++++++++++++++++-- 2 files changed, 196 insertions(+), 9 deletions(-)
tools/perf/Documentation/perf-stat.txt +4 -0
@@ -132,6 +132,10 @@ Print count deltas every N milliseconds (minimum: 10ms) The overhead percentage could be high in some cases, for instance with small, sub 100ms intervals. Use with caution. example: 'perf stat -I 1000 -e cycles -a sleep 5' +--metric-only:: +Only print computed metrics. Print them in a single line. +Don't show any raw values. Not supported with -A or --per-thread. + --per-socket:: Aggregate counts per processor socket for system-wide mode measurements. This is a useful mode to detect imbalance between sockets. To enable this mode,
tools/perf/builtin-stat.c +192 -9
308 lines not on this page · raw message
Signature · 1 line
2.1.4