From: Tim Chen <tim.c.chen@linux.intel.com>
To: Ian Rogers <irogers@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Kan Liang <kan.liang@linux.intel.com>,
John Garry <john.g.garry@oracle.com>,
Will Deacon <will@kernel.org>,
James Clark <james.clark@linaro.org>,
Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linux.dev>,
Yicong Yang <yangyicong@hisilicon.com>,
Weilin Wang <weilin.wang@intel.com>,
Thomas Richter <tmricht@linux.ibm.com>,
Sumanth Korikkar <sumanthk@linux.ibm.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 4/8] perf stat: Drop metric-unit if unit is NULL
Date: Tue, 08 Oct 2024 16:27:52 -0700 [thread overview]
Message-ID: <3fb7cc3fab054ad5b2af8a5ae5fd7dbdace774a2.camel@linux.intel.com> (raw)
In-Reply-To: <20241004234120.1495209-5-irogers@google.com>
On Fri, 2024-10-04 at 16:41 -0700, Ian Rogers wrote:
> 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)"}
> ...
> ```
>
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
> tools/perf/util/stat-display.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index e392ee5efb45..9b65968e37d1 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -470,8 +470,9 @@ 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);
> + fprintf(out, "\"metric-value\" : \"%f\"", val);
> + if (unit)
> + fprintf(out, ", \"metric-unit\" : \"%s\"", unit);
I think if there's no metric unit, we should skip printing metric value as a metric
of 0 has no meaning.
Tim
> if (!config->metric_only)
> fprintf(out, "}");
> }
next prev parent reply other threads:[~2024-10-08 23:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 23:41 [PATCH v1 0/8] CSV/JSON metric thresholds, fix printf modifiers Ian Rogers
2024-10-04 23:41 ` [PATCH v1 1/8] perf color: Add printf format checking and resolve issues Ian Rogers
2024-10-04 23:41 ` [PATCH v1 2/8] perf stat: Fix/add parameter names for print_metric Ian Rogers
2024-10-04 23:41 ` [PATCH v1 3/8] perf stat: Display "none" for NaN with metric only json Ian Rogers
2024-10-08 22:38 ` Namhyung Kim
2024-10-08 23:38 ` Ian Rogers
2024-10-04 23:41 ` [PATCH v1 4/8] perf stat: Drop metric-unit if unit is NULL Ian Rogers
2024-10-08 23:27 ` Tim Chen [this message]
2024-10-08 23:33 ` Ian Rogers
2024-10-04 23:41 ` [PATCH v1 5/8] perf stat: Change color to threshold in print_metric Ian Rogers
2024-10-04 23:41 ` [PATCH v1 6/8] perf stat: Display metric threshold value in CSV output Ian Rogers
2024-10-04 23:41 ` [PATCH v1 7/8] perf stat: Add metric-threshold to json output Ian Rogers
2024-10-04 23:41 ` [PATCH v1 8/8] perf stat: Disable metric thresholds for CSV/JSON metric-only mode Ian Rogers
2024-10-08 22:47 ` [PATCH v1 0/8] CSV/JSON metric thresholds, fix printf modifiers Namhyung Kim
2024-10-08 23:40 ` Ian Rogers
2024-10-10 0:59 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3fb7cc3fab054ad5b2af8a5ae5fd7dbdace774a2.camel@linux.intel.com \
--to=tim.c.chen@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=leo.yan@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=sumanthk@linux.ibm.com \
--cc=tmricht@linux.ibm.com \
--cc=weilin.wang@intel.com \
--cc=will@kernel.org \
--cc=yangyicong@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox