mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 06:14:39 +01: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 <[email protected]>
Signed-off-by: Ian Rogers <[email protected]>
Cc: Yicong Yang <[email protected]>
Cc: Weilin Wang <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: James Clark <[email protected]>
Cc: Mike Leach <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Sumanth Korikkar <[email protected]>
Cc: Thomas Richter <[email protected]>
Cc: Tim Chen <[email protected]>
Cc: John Garry <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
This commit is contained in:
1 parent
1133e7f7dc
commit
e1cc918b6c
1 file changed
+2
-2
@@ -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, "}");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user