Git fork

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 <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Christian Couder and committed by
Junio C Hamano
2e3efd06 c94b6ac5

+58 -1
+58 -1
t/perf/aggregate.perl
··· 37 37 } 38 38 39 39 my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests, 40 - $codespeed, $subsection, $reponame); 40 + $codespeed, $sortby, $subsection, $reponame); 41 41 while (scalar @ARGV) { 42 42 my $arg = $ARGV[0]; 43 43 my $dir; 44 44 if ($arg eq "--codespeed") { 45 45 $codespeed = 1; 46 46 shift @ARGV; 47 + next; 48 + } 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 + } 47 59 next; 48 60 } 49 61 if ($arg eq "--subsection") { ··· 209 221 } 210 222 } 211 223 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 + 212 267 sub print_codespeed_results { 213 268 my ($subsection) = @_; 214 269 ··· 263 318 264 319 if ($codespeed) { 265 320 print_codespeed_results($subsection); 321 + } elsif (defined $sortby) { 322 + print_sorted_results($sortby); 266 323 } else { 267 324 print_default_results(); 268 325 }