From patchwork Wed Jul 19 20:49:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 122837 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2713061vqt; Wed, 19 Jul 2023 14:17:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlFEtHXRM5ERb9BsGurMYbnY+czF64M2PCZbz5t73CtixwOFyLvyuWNHLkswfEav6asI81jS X-Received: by 2002:a05:6a20:8414:b0:133:fd64:8d48 with SMTP id c20-20020a056a20841400b00133fd648d48mr12680376pzd.4.1689801444858; Wed, 19 Jul 2023 14:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689801444; cv=none; d=google.com; s=arc-20160816; b=cADYkH4YKquH8+fPDrP2phC5H9M/CVmSlywhpCTtVZioBrxXcKtgI9PsagYVmhler4 9CMnWAVqQBRqGQ8TeUkz//E4xjFDbY0h+TkvOanUVB4QMb5a6VqcaP1fy5Amv+f3GIlc hD57OKgpgKwL5ywhwucwt2ax7t90fw3Ue23m/uVvhwblRii3LDaHMEaK2S6zkd6zkzOf culQSxt7Re42I5f0xYolvMYaRAeqWKolb/iB13LLOMqelEqkfhcWxoZ7ld5nhShZyjE8 YL4d5T6Vt4y1Ib+91z+Az+JieQjXJZo2YN+OqdyMQvT9jtKLdfYR5l9fw5RccetotHJ8 BdFA== 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 :dkim-signature; bh=11h9wZpZPoBQdv66/QeX1XthsxriDdZfYVTYgxC/xsI=; fh=+f/UgXFaEXexPSiEzT8nRacxrlb6xSaAhUFMhN/xNro=; b=0vk0IFDxvgc60O2x7+fWzd0tcOluwZsJVD0EufW1hTW5XafKqynSEI8W1eYuguivvJ BLBYS4Y/OQaGW9oOHzqKG8QeNheDju93QknmPzT+fzoxsQFF5+tTxUEJm1d1uLcFVQM2 q3Ilx7YzNpBeh9yzuskgPfkb2OUECeQwGNrekA1n826+RDqO024YI10nhA/jGTcRi78P +1GvZNylwmOvInN1NZydofn+oHjlhoCCwrz05e8O62VytARbhxjT6ONs27SC7Cf4p0UL tiGyTgxVJxTIKRy2Y2F2rEj/QlWPMq3sZXFpSSX81C7nMthEXeEe4djT+AxN+t1XRGw8 Ik3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dEXRxMJr; 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 w65-20020a636244000000b0053ee9b21820si4126041pgb.72.2023.07.19.14.17.12; Wed, 19 Jul 2023 14:17:24 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=dEXRxMJr; 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 S230492AbjGSUtg (ORCPT + 99 others); Wed, 19 Jul 2023 16:49:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbjGSUtd (ORCPT ); Wed, 19 Jul 2023 16:49:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36BF21FED; Wed, 19 Jul 2023 13:49:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C448B6183B; Wed, 19 Jul 2023 20:49:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDFC0C433C9; Wed, 19 Jul 2023 20:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689799771; bh=UpIXw98xleRtWat9gzqiYLTx+YUEV/h5AHcduRz0D+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dEXRxMJrFP/XDIveNjZ0NxFNqYfaNvIfalXAk5YT1ma0zjp9vX2pXPbD+VdYFBFgm cB8AZjF3cwGd/0alqe7e0/D2wU9Bc1syjBdbq5ZuZfOAaqZN2qRMUgA5yOfAAjSq6I AAjQwjOIKdrjs7hYAUeQrLOwDVkKPqNwu59FQiH7qeH32Ocy07bPfq63bbNHKzArFo y2j56WisF0Eh8oGHw6YR7MShJXoC6w37Vu0E4smV8Vk+hEc57txDVNVYeuokFP1NDK +LjwGf/20R2T19WZmOdN42bb50g5TLNizg2R+dW72u9FONA/Bmoax9ezf4imqQih9E nnzgj5KFoEN1A== From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Thomas Gleixner , Jiri Olsa , Ian Rogers , Adrian Hunter , Clark Williams , Kate Carcia , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Arnaldo Carvalho de Melo , Andre Fredette , Dave Tucker , Derek Barbosa , Masami Hiramatsu Subject: [PATCH 2/5] perf bench uprobe: Print diff to baseline Date: Wed, 19 Jul 2023 17:49:07 -0300 Message-ID: <20230719204910.539044-3-acme@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230719204910.539044-1-acme@kernel.org> References: <20230719204910.539044-1-acme@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: INBOX X-GMAIL-THRID: 1771885239334333907 X-GMAIL-MSGID: 1771885239334333907 From: Arnaldo Carvalho de Melo This is just prep work to show the diff to the unmodified workload. Cc: Adrian Hunter Cc: Andre Fredette Cc: Clark Williams Cc: Dave Tucker Cc: Derek Barbosa Cc: Ian Rogers Cc: Jiri Olsa Cc: Masami Hiramatsu (Google) Cc: Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo Reviewed-by: Masami Hiramatsu (Google) --- tools/perf/bench/uprobe.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tools/perf/bench/uprobe.c b/tools/perf/bench/uprobe.c index 707174220a76701f..60e7c43298d8cf56 100644 --- a/tools/perf/bench/uprobe.c +++ b/tools/perf/bench/uprobe.c @@ -34,6 +34,29 @@ static const char * const bench_uprobe_usage[] = { NULL }; +static int bench_uprobe_format__default_fprintf(const char *name, const char *unit, u64 diff, FILE *fp) +{ + static u64 baseline; + s64 diff_to_baseline = diff - baseline; + int printed = fprintf(fp, "# Executed %'d %s calls\n", loops, name); + + printed += fprintf(fp, " %14s: %'" PRIu64 " %ss", "Total time", diff, unit); + + if (baseline) + printed += fprintf(fp, " %s%'" PRId64 " to baseline", diff_to_baseline > 0 ? "+" : "", diff_to_baseline); + + printed += fprintf(fp, "\n\n %'.3f %ss/op", (double)diff / (double)loops, unit); + + if (baseline) + printed += fprintf(fp, " %'.3f %ss/op to baseline", (double)diff_to_baseline / (double)loops, unit); + else + baseline = diff; + + fputc('\n', fp); + + return printed + 1; +} + static int bench_uprobe(int argc, const char **argv) { const char *name = "usleep(1000)", *unit = "usec"; @@ -56,9 +79,7 @@ static int bench_uprobe(int argc, const char **argv) switch (bench_format) { case BENCH_FORMAT_DEFAULT: - printf("# Executed %'d %s calls\n", loops, name); - printf(" %14s: %'" PRIu64 " %ss\n\n", "Total time", diff, unit); - printf(" %'.3f %ss/op\n", (double)diff / (double)loops, unit); + bench_uprobe_format__default_fprintf(name, unit, diff, stdout); break; case BENCH_FORMAT_SIMPLE: