Namhyung Kim fdc7d60824 perf stat: Fix --metric-only --json output
Currently it prints all metric headers for JSON output.  But actually it
skips some metrics with valid_only_metric().  So the output looks like:

  $ perf stat --metric-only --json true
  {"unit" : "CPUs utilized", "unit" : "/sec", "unit" : "/sec", "unit" : "/sec", "unit" : "GHz", "unit" : "insn per cycle", "unit" : "/sec", "unit" : "branch-misses of all branches"}
  {"metric-value" : "3.861"}{"metric-value" : "0.79"}{"metric-value" : "3.04"}

As you can see there are 8 units in the header but only 3 metric-values
are there.  It should skip the unused headers as well.  Also each unit
should be printed as a separate object like metric values.

With this patch:

  $ perf stat --metric-only --json true
  {"unit" : "GHz"}{"unit" : "insn per cycle"}{"unit" : "branch-misses of all branches"}
  {"metric-value" : "4.166"}{"metric-value" : "0.73"}{"metric-value" : "2.96"}

Fixes: df936cadfb58ba93 ("perf stat: Add JSON output option")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Claire Jensen <cjense@google.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20221107213314.3239159-6-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-11-14 13:21:19 -03:00
..
2022-01-12 17:01:38 -08:00
2022-06-28 12:05:25 -03:00
2022-10-04 08:55:21 -03:00
2022-10-04 08:55:22 -03:00
2022-10-04 08:55:22 -03:00
2021-09-03 08:15:10 -03:00
2021-04-29 10:30:58 -03:00
2021-08-11 09:35:44 -03:00
2022-10-04 08:55:20 -03:00
2022-06-23 11:54:22 -03:00
2022-10-04 08:55:22 -03:00
2022-10-04 08:55:22 -03:00
2022-10-06 08:03:52 -03:00
2022-10-04 08:55:22 -03:00
2022-10-04 08:55:22 -03:00
2021-11-07 12:27:38 -03:00
2021-02-03 13:10:44 -03:00
2021-07-15 17:30:22 -03:00
2022-02-14 16:56:32 -03:00
2022-10-04 08:55:22 -03:00
2022-10-04 08:55:22 -03:00
2022-10-04 08:55:22 -03:00
2022-10-04 08:55:22 -03:00
2022-10-04 08:55:22 -03:00
2019-01-25 15:12:09 +01:00
2020-10-14 13:34:26 -03:00
2021-02-17 15:15:06 -03:00
2022-10-04 08:55:23 -03:00
2022-06-23 11:54:22 -03:00
2022-10-04 08:55:20 -03:00