From patchwork Mon Nov 14 23:02:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namhyung Kim X-Patchwork-Id: 20067 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2408413wru; Mon, 14 Nov 2022 15:04:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf5at0NoJ40kvvyo5onk1Gs+l+pYSJelMJ2dLVIMoD17DL5pk1SehaxEMblTVkuMKj7Gpmie X-Received: by 2002:a05:6402:5384:b0:458:4868:814 with SMTP id ew4-20020a056402538400b0045848680814mr12753827edb.190.1668467088222; Mon, 14 Nov 2022 15:04:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668467088; cv=none; d=google.com; s=arc-20160816; b=O2QjXOpb38Nh3bvJ/ZTamRWGfzuR889yUbpEhdRCjYtd2Ua722jGxDhwr0d8asn5Mp 5pxiDhqHEvdEr86iqaS4++3fHUoJJk3Kd41o+21qDHrrwRm34SZMDrWyzZWyaGZ0vlHf Z7M01BfuSBnJYEWEvn/KVcE7jiKhGdGbzt7ghIE4bpAOw/lQtsw4KjBGe1BgP+IjUVbP 3BOpWhi4Z4JGaj8EwqbjM2SBnHSqP/IQpDwG4Zevc2qPj6u7zXi07S0xMiQ6y0QAfQIR hFCoXauIERCe6RZRidcKuNcnG+1LoLhrG1F1YIWeYlxQ/kLM7srLlJpNUMhdMqjAOk4S UQ8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=mLjySvlGPKnVQ41FH3ZyjLNiZRwop922hNhTc7oubmw=; b=axycRcxGxehAxw2u8n+jSv81EDpgTtvPyLOrk+PyWyCUsCYlKnb9IJ4l8X1DHOGG8d OD6GA6wgdk5erlCrRTjoP3kHClAc65fliGwQwwkKEJMwVTvvh5UBzEftL+rxoghcCDZ3 5t0QKdQEf8ri/eyEYyeZ0mjXLKC6d36YiccRCpdGhdvlPVJ91AECnRsajhBN3i4Ar06k gGyLi5+RU/tZIolaB0hJWM5jBvYnl0s0b/87YFYFpYfy58dA8uw6fB22TbFBhrd2w+iB 2YxL/8sw12BZDFTyfvV64UTu6dKvh80Nj7d9ERvoObRUIyRG21KAHXVZr4n2W0MI+Ffw NBzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FaZabm5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b44-20020a509f2f000000b004573c1ae3fasi8622476edf.285.2022.11.14.15.04.23; Mon, 14 Nov 2022 15:04:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FaZabm5D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237896AbiKNXDH (ORCPT + 99 others); Mon, 14 Nov 2022 18:03:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237885AbiKNXCi (ORCPT ); Mon, 14 Nov 2022 18:02:38 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39E9A1BE88; Mon, 14 Nov 2022 15:02:35 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id 6so11574808pgm.6; Mon, 14 Nov 2022 15:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=mLjySvlGPKnVQ41FH3ZyjLNiZRwop922hNhTc7oubmw=; b=FaZabm5DuOJ6hbUuo766RDOgcgo+o1/sjEMrbcLhz4lgO60PfZOSeQsv/uyZZeNGLp EvRuZ2zhPm7Nrcrvl1v6cCUtBw1np5SvUWPBvalBi8pX5RrMI4jORhKZ2z264EvbOqxa EYvnyGHmiVUOTOISIRVqEJ5GqpoauJabnPWNYHVa5o6pj7sbgX0ANgmz60x3I5Z1YPoM 95OnMYnisQii8xJQ5UDcXi7fMBs9L15T83Ri22X77SBThVFJ9q6D9iH3AlJfq80y2s3w 2vttHGPNs+IqEpUHuC3aP5qtINeLHOMRq9ga8tKwyRufIlOJe7Euk+kR2Kr6I1XmFPxh CeDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mLjySvlGPKnVQ41FH3ZyjLNiZRwop922hNhTc7oubmw=; b=3o0zkLHzcQX2QclwK01TeSUlaHAS2VLXs+dgNU6pzYi5Ajj7bXBhJTLiOJXXrPgPhb Bb5Rnt8jt5M0UlndRFtyK0sakr04fh4f2KG2gABe4QRmY2VQqgosCPTc/rgfM9zxTizF K20eXL+xpY4yTHDj4Zg3fPoH1PnPJy2UiHZvwb475d+YyvbIQjY3gArF5U3bZr3xyvTt Pz7D/GusU5JChaU/UE/Bsw8yrMHAjGW7fZSB2yoyxdYS/+NbF5LiQmHie0PwgVK/bnFa OE4OE9Wmb0ZxWvWyinzKHJYiAVpUGLf2iTtAi5rCxy5hN/ivGdZhoyaElsewRKMnKBGz 7hKA== X-Gm-Message-State: ANoB5plB8TQZCe/4rSV83dVCNqy0mLaKW4RNqOU87d4uDivFREOcVXLQ dTA6535Hd14m5DIpUkZnPm4= X-Received: by 2002:a63:2243:0:b0:457:f843:ffcd with SMTP id t3-20020a632243000000b00457f843ffcdmr13400685pgm.101.1668466954619; Mon, 14 Nov 2022 15:02:34 -0800 (PST) Received: from balhae.hsd1.ca.comcast.net ([2601:647:6780:a80:cf9f:e038:c19b:797e]) by smtp.gmail.com with ESMTPSA id 132-20020a62148a000000b0056c814a501dsm7534724pfu.10.2022.11.14.15.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Nov 2022 15:02:34 -0800 (PST) Sender: Namhyung Kim From: Namhyung Kim To: Arnaldo Carvalho de Melo , Jiri Olsa Cc: Ingo Molnar , Peter Zijlstra , LKML , Ian Rogers , Adrian Hunter , linux-perf-users@vger.kernel.org, Kan Liang , Zhengjun Xing , James Clark , Athira Jajeev Subject: [PATCH 03/19] perf stat: Split print_noise_pct() function Date: Mon, 14 Nov 2022 15:02:11 -0800 Message-Id: <20221114230227.1255976-4-namhyung@kernel.org> X-Mailer: git-send-email 2.38.1.493.g58b659f92b-goog In-Reply-To: <20221114230227.1255976-1-namhyung@kernel.org> References: <20221114230227.1255976-1-namhyung@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749514545267698531?= X-GMAIL-MSGID: =?utf-8?q?1749514545267698531?= Likewise, split print_noise_pct() for each output mode. Although it's a tiny function, more logic will be added soon so it'd be better split it and treat it in the same way. Signed-off-by: Namhyung Kim --- tools/perf/util/stat-display.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c index 281b811f8574..a230f65efa62 100644 --- a/tools/perf/util/stat-display.c +++ b/tools/perf/util/stat-display.c @@ -62,17 +62,36 @@ static void print_running(struct perf_stat_config *config, print_running_std(config, run, ena); } +static void print_noise_pct_std(struct perf_stat_config *config, + double pct) +{ + if (pct) + fprintf(config->output, " ( +-%6.2f%% )", pct); +} + +static void print_noise_pct_csv(struct perf_stat_config *config, + double pct) +{ + fprintf(config->output, "%s%.2f%%", config->csv_sep, pct); +} + +static void print_noise_pct_json(struct perf_stat_config *config, + double pct) +{ + fprintf(config->output, "\"variance\" : %.2f, ", pct); +} + static void print_noise_pct(struct perf_stat_config *config, double total, double avg) { double pct = rel_stddev_stats(total, avg); if (config->json_output) - fprintf(config->output, "\"variance\" : %.2f, ", pct); + print_noise_pct_json(config, pct); else if (config->csv_output) - fprintf(config->output, "%s%.2f%%", config->csv_sep, pct); - else if (pct) - fprintf(config->output, " ( +-%6.2f%% )", pct); + print_noise_pct_csv(config, pct); + else + print_noise_pct_std(config, pct); } static void print_noise(struct perf_stat_config *config,