[PATCH 3/5] perf bench uprobe: Show diff to previous

From: Arnaldo Carvalho de Melo
Date: Wed Jul 19 2023 - 16:49:47 EST


From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Will be useful to show the incremental overhead as we do more stuff in
the BPF program attached to the uprobes.

Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Andre Fredette <anfredet@xxxxxxxxxx>
Cc: Clark Williams <williams@xxxxxxxxxx>
Cc: Dave Tucker <datucker@xxxxxxxxxx>
Cc: Derek Barbosa <debarbos@xxxxxxxxxx>
Cc: Ian Rogers <irogers@xxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/bench/uprobe.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/tools/perf/bench/uprobe.c b/tools/perf/bench/uprobe.c
index 60e7c43298d8cf56..a90e09f791c540a9 100644
--- a/tools/perf/bench/uprobe.c
+++ b/tools/perf/bench/uprobe.c
@@ -36,24 +36,35 @@ static const char * const bench_uprobe_usage[] = {

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;
+ static u64 baseline, previous;
+ s64 diff_to_baseline = diff - baseline,
+ diff_to_previous = diff - previous;
int printed = fprintf(fp, "# Executed %'d %s calls\n", loops, name);

printed += fprintf(fp, " %14s: %'" PRIu64 " %ss", "Total time", diff, unit);

- if (baseline)
+ if (baseline) {
printed += fprintf(fp, " %s%'" PRId64 " to baseline", diff_to_baseline > 0 ? "+" : "", diff_to_baseline);

+ if (previous != baseline)
+ fprintf(stdout, " %s%'" PRId64 " to previous", diff_to_previous > 0 ? "+" : "", diff_to_previous);
+ }
+
printed += fprintf(fp, "\n\n %'.3f %ss/op", (double)diff / (double)loops, unit);

- if (baseline)
+ if (baseline) {
printed += fprintf(fp, " %'.3f %ss/op to baseline", (double)diff_to_baseline / (double)loops, unit);
- else
+
+ if (previous != baseline)
+ printed += fprintf(fp, " %'.3f %ss/op to previous", (double)diff_to_previous / (double)loops, unit);
+ } else {
baseline = diff;
+ }

fputc('\n', fp);

+ previous = diff;
+
return printed + 1;
}

--
2.41.0