Skip to contentSkip to conversation

Support --metric-only in perf

PATCH New Andi Kleen 1 participant 3 messages Dec 16, 2015 perf events

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

Support --metric-only to only output metrics in perf stat. This can give much more concise and easier to read output in some situations.

Plus one bug fix.

This patchkit is on top of the earlier posted perf stat metrics refactoring patches.

author
#1 lore raw

PATCH 1/2 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.

v2: Lots of updates.

---
 tools/perf/Documentation/perf-stat.txt |   4 +
 tools/perf/builtin-stat.c              | 210 +++++++++++++++++++++++++++++++--
 2 files changed, 204 insertions(+), 10 deletions(-)
tools/perf/Documentation/perf-stat.txt +4 -0
index 079b141..58296e7 100644
@@ -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 +200 -10

317 lines not on this page · raw message

Signature · 1 line
2.4.3
author
#2 lore raw

PATCH 2/2 perf, tools, stat: Fix indentation of counter running printout

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

Fix the indentation of the counter running printout for non supported counters.

---
 tools/perf/builtin-stat.c | 2 ++
 1 file changed, 2 insertions(+)
tools/perf/builtin-stat.c +2 -0
index a18db2b..4777355 100644
@@ -827,6 +827,8 @@ static void printout(int id, int nr, struct perf_evsel *counter, double uval,
 			fprintf(stat_config.output, "%s%s",
 				csv_sep, counter->cgrp->name);
 
+		pm(&os, NULL, NULL, "", 0);
+
 		print_running(run, ena);
 		return;
 	}
Signature · 1 line
2.4.3