From: Namhyung Kim <namhyung@kernel.org>
To: James Clark <james.clark@linaro.org>, irogers@google.com
Cc: linux-perf-users@vger.kernel.org, acme@kernel.org,
tim.c.chen@linux.intel.com, Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
Yicong Yang <yangyicong@hisilicon.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] perf stat: Also hide metric from JSON if units are an empty string
Date: Tue, 29 Oct 2024 17:42:29 -0700 [thread overview]
Message-ID: <ZyGA9cjrtbE_eWik@google.com> (raw)
In-Reply-To: <20241025090307.59127-3-james.clark@linaro.org>
Hello,
On Fri, Oct 25, 2024 at 10:03:05AM +0100, James Clark wrote:
> We decided to hide NULL metric units rather than showing it as "(null)",
> but on hybrid systems if the process doesn't hit a PMU you get an empty
> string metric unit instead. To make it consistent also remove empty
> strings.
>
> Note that metric-threshold is already hidden in this case without this
> change.
>
> Where a process only runs on cpu_core and never hits cpu_atom:
> Before:
> $ perf stat -j -- true
> ...
> {"counter-value" : "<not counted>", "unit" : "", "event" : "cpu_atom/branch-misses/", "event-runtime" : 0, "pcnt-running" : 0.00, "metric-value" : "0.000000", "metric-unit" : ""}
> {"counter-value" : "6326.000000", "unit" : "", "event" : "cpu_core/branch-misses/", "event-runtime" : 293786, "pcnt-running" : 100.00, "metric-value" : "3.553394", "metric-unit" : "of all branches", "metric-threshold" : "good"}
> ...
I guess you're talking about "metric-unit", not plain "unit", right?
Then please update the subject line to reduce the config.
Ian, can you please review?
Thanks,
Namhyung
>
> After:
> ...
> {"counter-value" : "<not counted>", "unit" : "", "event" : "cpu_atom/branch-misses/", "event-runtime" : 0, "pcnt-running" : 0.00}
> {"counter-value" : "5778.000000", "unit" : "", "event" : "cpu_core/branch-misses/", "event-runtime" : 282240, "pcnt-running" : 100.00, "metric-value" : "3.226797", "metric-unit" : "of all branches", "metric-threshold" : "good"}
> ...
>
> Signed-off-by: James Clark <james.clark@linaro.org>
> ---
> tools/perf/util/stat-display.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index a5d72f4a515c..9b7fd985a42a 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -506,7 +506,7 @@ static void print_metric_json(struct perf_stat_config *config __maybe_unused,
> struct outstate *os = ctx;
> FILE *out = os->fh;
>
> - if (unit) {
> + if (unit && strlen(unit)) {
> json_out(os, "\"metric-value\" : \"%f\", \"metric-unit\" : \"%s\"", val, unit);
> if (thresh != METRIC_THRESHOLD_UNKNOWN) {
> json_out(os, "\"metric-threshold\" : \"%s\"",
> --
> 2.34.1
>
next prev parent reply other threads:[~2024-10-30 0:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 9:03 [PATCH 0/2] perf stat: Fix trailing comma when there is no metric unit James Clark
2024-10-25 9:03 ` [PATCH 1/2] " James Clark
2024-10-25 9:03 ` [PATCH 2/2] perf stat: Also hide metric from JSON if units are an empty string James Clark
2024-10-30 0:42 ` Namhyung Kim [this message]
2024-10-30 2:45 ` Ian Rogers
2024-10-30 9:36 ` James Clark
2024-10-30 15:38 ` Ian Rogers
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=ZyGA9cjrtbE_eWik@google.com \
--to=namhyung@kernel.org \
--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=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tim.c.chen@linux.intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.