[PATCHSET 00/15] perf stat: Improve perf stat output (v2)

From: Namhyung Kim
Date: Wed Nov 23 2022 - 13:02:44 EST


Hello,

This is a continuation of my perf stat cleanup work focusing on the
metric-only mode with JSON output now. It's based on the previous
patchset which is already merged to acme/perf/core.

The JSON output + metric-only with aggregation has been broken for a
while. The last update fixed the crash but it still produced invalid
JSON objects. Also having a separate header and objects with their own
"metric-value" key is not convenient to process.

# perf stat -aj --metric-only --per-socket sleep 1
{"unit" : "GHz"}{"unit" : "insn per cycle"}{"unit" : "branch-misses of all branches"}
{"socket" : "S0", "aggregate-number" : 8, {"metric-value" : "0.809"}{"metric-value" : "2.10"}{"metric-value" : "0.37"}

So I removed the header and move the metric keys to the object. Then
it doesn't need separate objects anymore. The new output looks like:

# perf stat -aj --metric-only --per-socket sleep 1
{"socket" : "S0", "cpu-count" : 8, "GHz" : "0.817", "insn per cycle" : "2.15", "branch-misses of all branches" : "0.38"}

You can get it from 'perf/stat-display-v2' branch in

git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git

Thanks,
Namhyung

Namhyung Kim (15):
perf stat: Fix cgroup display in JSON output
perf stat: Move summary prefix printing logic in CSV output
perf stat: Do not align time prefix in CSV output
perf stat: Use scnprintf() in prepare_interval()
perf stat: Remove prefix argument in print_metric_headers()
perf stat: Remove metric_only argument in print_counter_aggrdata()
perf stat: Pass const char *prefix to display routines
perf stat: Use struct outstate in evlist__print_counters()
perf stat: Pass struct outstate to print_metric_begin()
perf stat: Pass struct outstate to printout()
perf stat: Do not pass runtime_stat to printout()
perf stat: Pass through struct outstate
perf stat: Fix JSON output in metric-only mode
perf stat: Rename "aggregate-number" to "cpu-count" in JSON
perf stat: Tidy up JSON metric-only output when no metrics

tools/perf/arch/x86/util/iostat.c | 4 +-
tools/perf/util/iostat.c | 3 +-
tools/perf/util/iostat.h | 4 +-
tools/perf/util/stat-display.c | 257 +++++++++++++++---------------
4 files changed, 133 insertions(+), 135 deletions(-)


base-commit: 63a3bf5e8d9e79ce456c8f73d4395a5a51d841b1
--
2.38.1.584.g0f3c55d4c2-goog