perf/aggregate: refactor printing results
As we want to implement another kind of output than the current output for the perf test results, let's refactor the existing code that outputs the results in its own print_default_results() function. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
6f5ecad6a5
commit
30ffff6ee2
|
@ -100,13 +100,6 @@ sub read_descr {
|
||||||
return $line;
|
return $line;
|
||||||
}
|
}
|
||||||
|
|
||||||
my %descrs;
|
|
||||||
my $descrlen = 4; # "Test"
|
|
||||||
for my $t (@subtests) {
|
|
||||||
$descrs{$t} = $shorttests{$t}.": ".read_descr("$resultsdir/$t.descr");
|
|
||||||
$descrlen = length $descrs{$t} if length $descrs{$t}>$descrlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub have_duplicate {
|
sub have_duplicate {
|
||||||
my %seen;
|
my %seen;
|
||||||
for (@_) {
|
for (@_) {
|
||||||
|
@ -122,24 +115,32 @@ sub have_slash {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my %newdirabbrevs = %dirabbrevs;
|
sub print_default_results {
|
||||||
while (!have_duplicate(values %newdirabbrevs)) {
|
my %descrs;
|
||||||
|
my $descrlen = 4; # "Test"
|
||||||
|
for my $t (@subtests) {
|
||||||
|
$descrs{$t} = $shorttests{$t}.": ".read_descr("$resultsdir/$t.descr");
|
||||||
|
$descrlen = length $descrs{$t} if length $descrs{$t}>$descrlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
my %newdirabbrevs = %dirabbrevs;
|
||||||
|
while (!have_duplicate(values %newdirabbrevs)) {
|
||||||
%dirabbrevs = %newdirabbrevs;
|
%dirabbrevs = %newdirabbrevs;
|
||||||
last if !have_slash(values %dirabbrevs);
|
last if !have_slash(values %dirabbrevs);
|
||||||
%newdirabbrevs = %dirabbrevs;
|
%newdirabbrevs = %dirabbrevs;
|
||||||
for (values %newdirabbrevs) {
|
for (values %newdirabbrevs) {
|
||||||
s{^[^/]*/}{};
|
s{^[^/]*/}{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my %times;
|
my %times;
|
||||||
my @colwidth = ((0)x@dirs);
|
my @colwidth = ((0)x@dirs);
|
||||||
for my $i (0..$#dirs) {
|
for my $i (0..$#dirs) {
|
||||||
my $d = $dirs[$i];
|
my $d = $dirs[$i];
|
||||||
my $w = length (exists $dirabbrevs{$d} ? $dirabbrevs{$d} : $dirnames{$d});
|
my $w = length (exists $dirabbrevs{$d} ? $dirabbrevs{$d} : $dirnames{$d});
|
||||||
$colwidth[$i] = $w if $w > $colwidth[$i];
|
$colwidth[$i] = $w if $w > $colwidth[$i];
|
||||||
}
|
}
|
||||||
for my $t (@subtests) {
|
for my $t (@subtests) {
|
||||||
my $firstr;
|
my $firstr;
|
||||||
for my $i (0..$#dirs) {
|
for my $i (0..$#dirs) {
|
||||||
my $d = $dirs[$i];
|
my $d = $dirs[$i];
|
||||||
|
@ -149,20 +150,18 @@ for my $t (@subtests) {
|
||||||
$colwidth[$i] = $w if $w > $colwidth[$i];
|
$colwidth[$i] = $w if $w > $colwidth[$i];
|
||||||
$firstr = $r unless defined $firstr;
|
$firstr = $r unless defined $firstr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $totalwidth = 3*@dirs+$descrlen;
|
my $totalwidth = 3*@dirs+$descrlen;
|
||||||
$totalwidth += $_ for (@colwidth);
|
$totalwidth += $_ for (@colwidth);
|
||||||
|
|
||||||
binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
|
printf "%-${descrlen}s", "Test";
|
||||||
|
for my $i (0..$#dirs) {
|
||||||
printf "%-${descrlen}s", "Test";
|
|
||||||
for my $i (0..$#dirs) {
|
|
||||||
my $d = $dirs[$i];
|
my $d = $dirs[$i];
|
||||||
printf " %-$colwidth[$i]s", (exists $dirabbrevs{$d} ? $dirabbrevs{$d} : $dirnames{$d});
|
printf " %-$colwidth[$i]s", (exists $dirabbrevs{$d} ? $dirabbrevs{$d} : $dirnames{$d});
|
||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
print "-"x$totalwidth, "\n";
|
print "-"x$totalwidth, "\n";
|
||||||
for my $t (@subtests) {
|
for my $t (@subtests) {
|
||||||
printf "%-${descrlen}s", $descrs{$t};
|
printf "%-${descrlen}s", $descrs{$t};
|
||||||
my $firstr;
|
my $firstr;
|
||||||
for my $i (0..$#dirs) {
|
for my $i (0..$#dirs) {
|
||||||
|
@ -172,4 +171,9 @@ for my $t (@subtests) {
|
||||||
$firstr = $r unless defined $firstr;
|
$firstr = $r unless defined $firstr;
|
||||||
}
|
}
|
||||||
print "\n";
|
print "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
|
||||||
|
|
||||||
|
print_default_results();
|
||||||
|
|
Loading…
Reference in New Issue