git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
	"Thomas Rast" <tr@thomasrast.ch>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Christian Couder" <chriscool@tuxfamily.org>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Philip Oakley" <philipoakley@iee.org>
Subject: [PATCH v2 2/2] perf/aggregate: add --sort-by=regression option
Date: Mon, 26 Mar 2018 09:24:31 +0200	[thread overview]
Message-ID: <20180326072431.30771-3-chriscool@tuxfamily.org> (raw)
In-Reply-To: <20180326072431.30771-1-chriscool@tuxfamily.org>

One of the most interesting thing one can be interested in when
looking at performance test results is possible performance
regressions.

This new option makes it easy to spot such possible regressions.

This new option is named '--sort-by=regression' to make it
possible and easy to add other ways to sort the results, like for
example '--sort-by=utime'.

If we would like to sort according to how much the stime regressed
we could also add a new option called '--sort-by=regression:stime'.
Then '--sort-by=regression' could become a synonym for
'--sort-by=regression:rtime'.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/perf/aggregate.perl | 59 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)

diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
index 890d85fa7b..48637ef64b 100755
--- a/t/perf/aggregate.perl
+++ b/t/perf/aggregate.perl
@@ -37,7 +37,7 @@ sub format_times {
 }
 
 my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
-    $codespeed, $subsection, $reponame);
+    $codespeed, $sortby, $subsection, $reponame);
 while (scalar @ARGV) {
 	my $arg = $ARGV[0];
 	my $dir;
@@ -46,6 +46,18 @@ while (scalar @ARGV) {
 		shift @ARGV;
 		next;
 	}
+	if ($arg =~ /--sort-by(?:=(.*))?/) {
+		shift @ARGV;
+		if (defined $1) {
+			$sortby = $1;
+		} else {
+			$sortby = shift @ARGV;
+			if (! defined $sortby) {
+				die "'--sort-by' requires an argument";
+			}
+		}
+		next;
+	}
 	if ($arg eq "--subsection") {
 		shift @ARGV;
 		$subsection = $ARGV[0];
@@ -209,6 +221,49 @@ sub print_default_results {
 	}
 }
 
+sub print_sorted_results {
+	my ($sortby) = @_;
+
+	if ($sortby ne "regression") {
+		die "only 'regression' is supported as '--sort-by' argument";
+	}
+
+	my @evolutions;
+	for my $t (@subtests) {
+		my ($prevr, $prevu, $prevs, $prevrev);
+		for my $i (0..$#dirs) {
+			my $d = $dirs[$i];
+			my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
+			if ($i > 0 and defined $r and defined $prevr and $prevr > 0) {
+				my $percent = 100.0 * ($r - $prevr) / $prevr;
+				push @evolutions, { "percent"  => $percent,
+						    "test"     => $t,
+						    "prevrev"  => $prevrev,
+						    "rev"      => $d,
+						    "prevr"    => $prevr,
+						    "r"        => $r,
+						    "prevu"    => $prevu,
+						    "u"        => $u,
+						    "prevs"    => $prevs,
+						    "s"        => $s};
+			}
+			($prevr, $prevu, $prevs, $prevrev) = ($r, $u, $s, $d);
+		}
+	}
+
+	my @sorted_evolutions = sort { $b->{percent} <=> $a->{percent} } @evolutions;
+
+	for my $e (@sorted_evolutions) {
+		printf "%+.1f%%", $e->{percent};
+		print " " . $e->{test};
+		print " " . format_times($e->{prevr}, $e->{prevu}, $e->{prevs});
+		print " " . format_times($e->{r}, $e->{u}, $e->{s});
+		print " " . display_dir($e->{prevrev});
+		print " " . display_dir($e->{rev});
+		print "\n";
+	}
+}
+
 sub print_codespeed_results {
 	my ($subsection) = @_;
 
@@ -263,6 +318,8 @@ binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
 
 if ($codespeed) {
 	print_codespeed_results($subsection);
+} elsif (defined $sortby) {
+	print_sorted_results($sortby);
 } else {
 	print_default_results();
 }
-- 
2.17.0.rc1.36.g098d832c9.dirty


      parent reply	other threads:[~2018-03-26  7:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-26  7:24 [PATCH v2 0/2] perf/aggregate: sort results by regression Christian Couder
2018-03-26  7:24 ` [PATCH v2 1/2] perf/aggregate: add display_dir() Christian Couder
2018-03-26  7:24 ` Christian Couder [this message]

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=20180326072431.30771-3-chriscool@tuxfamily.org \
    --to=christian.couder@gmail.com \
    --cc=avarab@gmail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=philipoakley@iee.org \
    --cc=sunshine@sunshineco.com \
    --cc=tr@thomasrast.ch \
    /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).