Skip to content

Commit 2e3efd0

Browse files
chriscoolgitster
authored andcommitted
perf/aggregate: add --sort-by=regression option
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c94b6ac commit 2e3efd0

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

t/perf/aggregate.perl

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ sub format_times {
3737
}
3838

3939
my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
40-
$codespeed, $subsection, $reponame);
40+
$codespeed, $sortby, $subsection, $reponame);
4141
while (scalar @ARGV) {
4242
my $arg = $ARGV[0];
4343
my $dir;
@@ -46,6 +46,18 @@ sub format_times {
4646
shift @ARGV;
4747
next;
4848
}
49+
if ($arg =~ /--sort-by(?:=(.*))?/) {
50+
shift @ARGV;
51+
if (defined $1) {
52+
$sortby = $1;
53+
} else {
54+
$sortby = shift @ARGV;
55+
if (! defined $sortby) {
56+
die "'--sort-by' requires an argument";
57+
}
58+
}
59+
next;
60+
}
4961
if ($arg eq "--subsection") {
5062
shift @ARGV;
5163
$subsection = $ARGV[0];
@@ -209,6 +221,49 @@ sub print_default_results {
209221
}
210222
}
211223

224+
sub print_sorted_results {
225+
my ($sortby) = @_;
226+
227+
if ($sortby ne "regression") {
228+
die "only 'regression' is supported as '--sort-by' argument";
229+
}
230+
231+
my @evolutions;
232+
for my $t (@subtests) {
233+
my ($prevr, $prevu, $prevs, $prevrev);
234+
for my $i (0..$#dirs) {
235+
my $d = $dirs[$i];
236+
my ($r, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
237+
if ($i > 0 and defined $r and defined $prevr and $prevr > 0) {
238+
my $percent = 100.0 * ($r - $prevr) / $prevr;
239+
push @evolutions, { "percent" => $percent,
240+
"test" => $t,
241+
"prevrev" => $prevrev,
242+
"rev" => $d,
243+
"prevr" => $prevr,
244+
"r" => $r,
245+
"prevu" => $prevu,
246+
"u" => $u,
247+
"prevs" => $prevs,
248+
"s" => $s};
249+
}
250+
($prevr, $prevu, $prevs, $prevrev) = ($r, $u, $s, $d);
251+
}
252+
}
253+
254+
my @sorted_evolutions = sort { $b->{percent} <=> $a->{percent} } @evolutions;
255+
256+
for my $e (@sorted_evolutions) {
257+
printf "%+.1f%%", $e->{percent};
258+
print " " . $e->{test};
259+
print " " . format_times($e->{prevr}, $e->{prevu}, $e->{prevs});
260+
print " " . format_times($e->{r}, $e->{u}, $e->{s});
261+
print " " . display_dir($e->{prevrev});
262+
print " " . display_dir($e->{rev});
263+
print "\n";
264+
}
265+
}
266+
212267
sub print_codespeed_results {
213268
my ($subsection) = @_;
214269

@@ -263,6 +318,8 @@ sub print_codespeed_results {
263318

264319
if ($codespeed) {
265320
print_codespeed_results($subsection);
321+
} elsif (defined $sortby) {
322+
print_sorted_results($sortby);
266323
} else {
267324
print_default_results();
268325
}

0 commit comments

Comments
 (0)