From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Clark Williams <williams@redhat.com>,
Kate Carcia <kcarcia@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Andre Fredette <anfredet@redhat.com>,
Dave Tucker <datucker@redhat.com>,
Derek Barbosa <debarbos@redhat.com>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [PATCH 2/5] perf bench uprobe: Print diff to baseline
Date: Fri, 21 Jul 2023 23:43:55 +0900 [thread overview]
Message-ID: <20230721234355.b0a7ae245a2010d4a5c08a52@kernel.org> (raw)
In-Reply-To: <20230719204910.539044-3-acme@kernel.org>
On Wed, 19 Jul 2023 17:49:07 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> This is just prep work to show the diff to the unmodified workload.
Looks good to me, just one comment below.
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Andre Fredette <anfredet@redhat.com>
> Cc: Clark Williams <williams@redhat.com>
> Cc: Dave Tucker <datucker@redhat.com>
> Cc: Derek Barbosa <debarbos@redhat.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> ---
> 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);
Just a nit, do we need to repeat (double) cast on the denominator side too?
> +
> + 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:
> --
> 2.41.0
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2023-07-21 14:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-19 20:49 [PATCHES/RFC 1/5] perf bench uprobe + BPF skel Arnaldo Carvalho de Melo
2023-07-19 20:49 ` [PATCH 1/5] perf bench uprobe: Add benchmark to test uprobe overhead Arnaldo Carvalho de Melo
2023-07-21 14:45 ` Masami Hiramatsu
2023-07-19 20:49 ` [PATCH 2/5] perf bench uprobe: Print diff to baseline Arnaldo Carvalho de Melo
2023-07-21 14:43 ` Masami Hiramatsu [this message]
2023-07-19 20:49 ` [PATCH 3/5] perf bench uprobe: Show diff to previous Arnaldo Carvalho de Melo
2023-07-21 14:48 ` Masami Hiramatsu
2023-07-19 20:49 ` [PATCH 4/5] perf bench uprobe empty: Add entry attaching an empty BPF program Arnaldo Carvalho de Melo
2023-07-19 20:49 ` [PATCH 5/5] perf bench uprobe trace_printk: Add entry attaching an BPF program that does a trace_printk Arnaldo Carvalho de Melo
2023-07-19 22:41 ` [PATCHES/RFC 1/5] perf bench uprobe + BPF skel Ian Rogers
2023-07-20 13:56 ` Arnaldo Carvalho de Melo
2023-07-21 14:32 ` Masami Hiramatsu
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=20230721234355.b0a7ae245a2010d4a5c08a52@kernel.org \
--to=mhiramat@kernel.org \
--cc=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=anfredet@redhat.com \
--cc=datucker@redhat.com \
--cc=debarbos@redhat.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kcarcia@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.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;
as well as URLs for NNTP newsgroup(s).