3 use lib
'../../perl/build/lib';
11 open my $fh, "<", $name or return undef;
13 return undef if not defined $line;
14 close $fh or die "cannot close $name: $!";
15 $line =~ /^(?:(\d+):)?(\d+):(\d+(?:\.\d+)?) (\d+(?:\.\d+)?) (\d+(?:\.\d+)?)$/
16 or die "bad input line: $line";
17 my $rt = ((defined $1 ?
$1 : 0.0)*60+$2)*60+$3;
22 my ($r, $u, $s, $firstr) = @_;
26 my $out = sprintf "%.2f(%.2f+%.2f)", $r, $u, $s;
27 if (defined $firstr) {
29 $out .= sprintf " %+.1f%%", 100.0*($r-$firstr)/$firstr;
39 my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
40 $codespeed, $subsection, $reponame);
41 while (scalar @ARGV) {
44 if ($arg eq "--codespeed") {
49 if ($arg eq "--subsection") {
51 $subsection = $ARGV[0];
54 die "empty subsection";
58 if ($arg eq "--reponame") {
67 last if -f
$arg or $arg eq "--";
69 my $rev = Git
::command_oneline
(qw(rev-parse --verify), $arg);
74 $dirabbrevs{$dir} = $dir;
77 $dirnames{$dir} = $arg;
79 $prefix =~ tr/^a-zA-Z0-9/_/c;
80 $prefixes{$dir} = $prefix . '.';
87 $dirnames{'.'} = $dirabbrevs{'.'} = "this tree";
90 shift @ARGV if scalar @ARGV and $ARGV[0] eq "--";
94 @tests = glob "p????-*.sh";
97 my $resultsdir = "test-results";
100 exists $ENV{GIT_PERF_SUBSECTION
} and
101 $ENV{GIT_PERF_SUBSECTION
} ne "") {
102 $subsection = $ENV{GIT_PERF_SUBSECTION
};
106 $resultsdir .= "/" . $subsection;
112 $t =~ s{(?:.*/)?(p(\d+)-[^/]+)\.sh$}{$1} or die "bad test name: $t";
114 my $fname = "$resultsdir/$t.subtests";
115 open my $fp, "<", $fname or die "cannot open $fname: $!";
118 /^(\d+)$/ or die "malformed subtest line: $_";
119 push @subtests, "$t.$1";
120 $shorttests{"$t.$1"} = "$n.$1";
122 close $fp or die "cannot close $fname: $!";
127 open my $fh, "<", $name or return "<error reading description>";
128 binmode $fh, ":utf8" or die "PANIC on binmode: $!";
130 close $fh or die "cannot close $name";
138 return 1 if exists $seen{$_};
150 sub print_default_results
{
152 my $descrlen = 4; # "Test"
153 for my $t (@subtests) {
154 $descrs{$t} = $shorttests{$t}.": ".read_descr
("$resultsdir/$t.descr");
155 $descrlen = length $descrs{$t} if length $descrs{$t}>$descrlen;
158 my %newdirabbrevs = %dirabbrevs;
159 while (!have_duplicate
(values %newdirabbrevs)) {
160 %dirabbrevs = %newdirabbrevs;
161 last if !have_slash
(values %dirabbrevs);
162 %newdirabbrevs = %dirabbrevs;
163 for (values %newdirabbrevs) {
169 my @colwidth = ((0)x
@dirs);
170 for my $i (0..$#dirs) {
172 my $w = length (exists $dirabbrevs{$d} ?
$dirabbrevs{$d} : $dirnames{$d});
173 $colwidth[$i] = $w if $w > $colwidth[$i];
175 for my $t (@subtests) {
177 for my $i (0..$#dirs) {
179 $times{$prefixes{$d}.$t} = [get_times
("$resultsdir/$prefixes{$d}$t.times")];
180 my ($r,$u,$s) = @
{$times{$prefixes{$d}.$t}};
181 my $w = length format_times
($r,$u,$s,$firstr);
182 $colwidth[$i] = $w if $w > $colwidth[$i];
183 $firstr = $r unless defined $firstr;
186 my $totalwidth = 3*@dirs+$descrlen;
187 $totalwidth += $_ for (@colwidth);
189 printf "%-${descrlen}s", "Test";
190 for my $i (0..$#dirs) {
192 printf " %-$colwidth[$i]s", (exists $dirabbrevs{$d} ?
$dirabbrevs{$d} : $dirnames{$d});
195 print "-"x
$totalwidth, "\n";
196 for my $t (@subtests) {
197 printf "%-${descrlen}s", $descrs{$t};
199 for my $i (0..$#dirs) {
201 my ($r,$u,$s) = @
{$times{$prefixes{$d}.$t}};
202 printf " %-$colwidth[$i]s", format_times
($r,$u,$s,$firstr);
203 $firstr = $r unless defined $firstr;
209 sub print_codespeed_results
{
210 my ($subsection) = @_;
214 my $executable = `uname -s -m`;
218 $executable .= ", " . $subsection;
223 $environment = $reponame;
224 } elsif (exists $ENV{GIT_PERF_REPO_NAME
} and $ENV{GIT_PERF_REPO_NAME
} ne "") {
225 $environment = $ENV{GIT_PERF_REPO_NAME
};
226 } elsif (exists $ENV{GIT_TEST_INSTALLED
} and $ENV{GIT_TEST_INSTALLED
} ne "") {
227 $environment = $ENV{GIT_TEST_INSTALLED
};
228 $environment =~ s
|/bin
-wrappers
$||;
230 $environment = `uname -r`;
236 for my $t (@subtests) {
238 my $commitid = $prefixes{$d};
239 $commitid =~ s/^build_//;
240 $commitid =~ s/\.$//;
241 my ($result_value, $u, $s) = get_times
("$resultsdir/$prefixes{$d}$t.times");
244 "commitid" => $commitid,
245 "project" => $project,
246 "branch" => $dirnames{$d},
247 "executable" => $executable,
248 "benchmark" => $shorttests{$t} . " " . read_descr
("$resultsdir/$t.descr"),
249 "environment" => $environment,
250 "result_value" => $result_value,
256 print to_json
(\
@data, {utf8
=> 1, pretty
=> 1, canonical
=> 1}), "\n";
259 binmode STDOUT
, ":utf8" or die "PANIC on binmode: $!";
262 print_codespeed_results
($subsection);
264 print_default_results
();