mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
perf stat: Drop metric-unit if unit is NULL
Avoid cases like: ``` $ perf stat -a -M topdownl1 -j -I 1000 ... {"interval" : 11.127757275, "counter-value" : "85715898.000000", "unit" : "", "event" : "IDQ.MITE_UOPS", "event-runtime" : 988376123, "pcnt-running" : 100.00, "metric-value" : "0.000000", "metric-unit" : "(null)"} ... ``` If there is no unit then drop the metric-value too as: Suggested-by: Tim Chen <tim.c.chen@linux.intel.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Yicong Yang <yangyicong@hisilicon.com> Cc: Weilin Wang <weilin.wang@intel.com> Cc: Will Deacon <will@kernel.org> Cc: James Clark <james.clark@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Leo Yan <leo.yan@linux.dev> Cc: Sumanth Korikkar <sumanthk@linux.ibm.com> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: Tim Chen <tim.c.chen@linux.intel.com> Cc: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20241017175356.783793-5-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
parent
1133e7f7dc
commit
e1cc918b6c
1 changed files with 2 additions and 2 deletions
|
@ -471,8 +471,8 @@ static void print_metric_json(struct perf_stat_config *config __maybe_unused,
|
|||
struct outstate *os = ctx;
|
||||
FILE *out = os->fh;
|
||||
|
||||
fprintf(out, "\"metric-value\" : \"%f\", ", val);
|
||||
fprintf(out, "\"metric-unit\" : \"%s\"", unit);
|
||||
if (unit)
|
||||
fprintf(out, "\"metric-value\" : \"%f\", \"metric-unit\" : \"%s\"", val, unit);
|
||||
if (!config->metric_only)
|
||||
fprintf(out, "}");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue