From nobody Wed Nov 27 14:34:32 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 312091773D for ; Thu, 10 Oct 2024 00:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728518860; cv=none; b=JDBrpvOQ1HVThwTxyWuRlTEjEoy5rOog9FqlEa2aeKxb7eLqEOxgYGmFL3z5Kq7Ye9BlAuRdYJgqOF+xytKDk95bu+yX1JqJgMWlWOYvOwrNpR+KgYJescXlinnwyZhXm4u+WhFiZ7BlDnZWMCXehAAwTnexXEXPIDyFRc3Hl6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728518860; c=relaxed/simple; bh=1azV7E7FNm5ZgpAvEIdQ64JI8F44TJjzhA8h4p43pa4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=EgWWASYtkK0YeBXML/G5QrnfmLOozPw81lYYEs6+4siXy7td9kE46ncuuC5aQIWu9nNeYuBT9X6lFzZAmX6XNP8aSnOuMk8BGBMad7xX2n7Z0UeP+xOEReFLHmlyMHglOZd43jOE9MvTLObw+H+6QrtEeQyOne5lGka6Ruwzwdo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RGieEpAe; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RGieEpAe" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e2e4874925so8057247b3.1 for ; Wed, 09 Oct 2024 17:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728518858; x=1729123658; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=H1XFcCPRE5WoawTRbLhb/GdnJyywM9jpDE6V/JQJDp0=; b=RGieEpAeKcEcm6ar4g37YNJ/+hhVQQ0v3QKEwbfxT8cIWzdyxPoT26P0C1LeU4FduR WbTetQ/hPDeLAbICJAYajGrcMQOnObKJDH7RJP6xoj+xDBYUdn9cx5ES+8mP/6Gxi381 6gdmGWEf35S3kdjQXWgOQZrkhVjXBNnfsiOQZ8vGbMPJBU4qdCiW17YPOJk+EfjofJV7 RYrfijZFmSKA3z+Ef6XRancPQgCqFUz8Jw6G2oK9KZdvA6RkfOOvPwTbmipNxdfWXiqQ g4szAFyUa/YjFApEnrYqsf+EQqwCU5dsqliDnNoSRN2HaW0FNkBnafsfTCXGPM0BGdRT 3g9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728518858; x=1729123658; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=H1XFcCPRE5WoawTRbLhb/GdnJyywM9jpDE6V/JQJDp0=; b=AO45GCRLn26V/O4Tsq1PEI96q7thIGhMXmlpcpwJ8w0L82kQL4MgETmWiV/r/h41Sm XEmrudIvxGn3KWzqY0ndYPzW3wwBkqMDNmC3nH/9/pFXUqpk655uLAGI9WjUWmIyzUXa uurnIxSAa+8ECW6DskBNdHg0ImKvjLom8/NTFfgHBxThTMiCUKLt40dZaS5XunwMpa/6 OfxMQr6mA1imU3f8bUsgki+LnoAYuIX5fWcNBhk/u5vQjbK72EPhthXIlyLSCNVfKPZn I8ZrRsgfr0m5flDqGLH/CykR0oOx7FKrUHOLHzROXMVjH9AxqGVnyj6GZtFevWLEuSF0 PNcQ== X-Forwarded-Encrypted: i=1; AJvYcCXicGJS5CDPQ1jDB00FI7cjNAhXsFRgYpFlw56qN59QonBjwXkuA8uE5kI0fko9sKv+EJSSp7Z7upvRBKM=@vger.kernel.org X-Gm-Message-State: AOJu0YyH0FIV79ej5e+FvCWdvxlTN82oXgeE/taMJ5uUEuf/d/VhGHy6 9RCiDSDe4FMW2yFERUwYtJvgEahB+MfAgBQH4aXnx/ktQRE11qKrTDIy0R1bYXc4WGE/RPpisQe B2fFzGQ== X-Google-Smtp-Source: AGHT+IHNoxyro9XdhuFfsc7bf+vWfsjYtcZE7l/ylvctEy37DlR4T6Q+7ItK2XwAF8/IOsc1WpU2LePV/ENR X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:6c8b:1170:a0ca:9d72]) (user=irogers job=sendgmr) by 2002:a05:690c:4a87:b0:6e2:70e:e82e with SMTP id 00721157ae682-6e3224227fcmr167887b3.6.1728518858075; Wed, 09 Oct 2024 17:07:38 -0700 (PDT) Date: Wed, 9 Oct 2024 17:07:17 -0700 In-Reply-To: <20241010000719.1172854-1-irogers@google.com> Message-Id: <20241010000719.1172854-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241010000719.1172854-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Subject: [PATCH v2 4/6] perf stat: Drop metric-unit if unit is NULL From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Yicong Yang , Weilin Wang , Tim Chen , Thomas Richter , Sumanth Korikkar , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Ian Rogers --- tools/perf/util/stat-display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index e392ee5efb45..6bb048fefe9d 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -470,8 +470,8 @@ static void print_metric_json(struct perf_stat_config *= config __maybe_unused, struct outstate *os =3D ctx; FILE *out =3D os->fh; =20 - 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, "}"); } --=20 2.47.0.rc1.288.g06298d1525-goog