|
3 | 3 | use lib '../../perl/blib/lib';
|
4 | 4 | use strict;
|
5 | 5 | use warnings;
|
| 6 | +use JSON; |
6 | 7 | use Git;
|
7 | 8 |
|
8 | 9 | sub get_times {
|
@@ -35,10 +36,15 @@ sub format_times {
|
35 | 36 | return $out;
|
36 | 37 | }
|
37 | 38 |
|
38 |
| -my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests); |
| 39 | +my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests, $codespeed); |
39 | 40 | while (scalar @ARGV) {
|
40 | 41 | my $arg = $ARGV[0];
|
41 | 42 | my $dir;
|
| 43 | + if ($arg eq "--codespeed") { |
| 44 | + $codespeed = 1; |
| 45 | + shift @ARGV; |
| 46 | + next; |
| 47 | + } |
42 | 48 | last if -f $arg or $arg eq "--";
|
43 | 49 | if (! -d $arg) {
|
44 | 50 | my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
|
@@ -70,8 +76,10 @@ sub format_times {
|
70 | 76 | }
|
71 | 77 |
|
72 | 78 | my $resultsdir = "test-results";
|
| 79 | +my $results_section = ""; |
73 | 80 | if (exists $ENV{GIT_PERF_SUBSECTION} and $ENV{GIT_PERF_SUBSECTION} ne "") {
|
74 | 81 | $resultsdir .= "/" . $ENV{GIT_PERF_SUBSECTION};
|
| 82 | + $results_section = $ENV{GIT_PERF_SUBSECTION}; |
75 | 83 | }
|
76 | 84 |
|
77 | 85 | my @subtests;
|
@@ -174,6 +182,58 @@ sub print_default_results {
|
174 | 182 | }
|
175 | 183 | }
|
176 | 184 |
|
| 185 | +sub print_codespeed_results { |
| 186 | + my ($results_section) = @_; |
| 187 | + |
| 188 | + my $project = "Git"; |
| 189 | + |
| 190 | + my $executable = `uname -s -m`; |
| 191 | + chomp $executable; |
| 192 | + |
| 193 | + if ($results_section ne "") { |
| 194 | + $executable .= ", " . $results_section; |
| 195 | + } |
| 196 | + |
| 197 | + my $environment; |
| 198 | + if (exists $ENV{GIT_PERF_REPO_NAME} and $ENV{GIT_PERF_REPO_NAME} ne "") { |
| 199 | + $environment = $ENV{GIT_PERF_REPO_NAME}; |
| 200 | + } elsif (exists $ENV{GIT_TEST_INSTALLED} and $ENV{GIT_TEST_INSTALLED} ne "") { |
| 201 | + $environment = $ENV{GIT_TEST_INSTALLED}; |
| 202 | + $environment =~ s|/bin-wrappers$||; |
| 203 | + } else { |
| 204 | + $environment = `uname -r`; |
| 205 | + chomp $environment; |
| 206 | + } |
| 207 | + |
| 208 | + my @data; |
| 209 | + |
| 210 | + for my $t (@subtests) { |
| 211 | + for my $d (@dirs) { |
| 212 | + my $commitid = $prefixes{$d}; |
| 213 | + $commitid =~ s/^build_//; |
| 214 | + $commitid =~ s/\.$//; |
| 215 | + my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times"); |
| 216 | + |
| 217 | + my %vals = ( |
| 218 | + "commitid" => $commitid, |
| 219 | + "project" => $project, |
| 220 | + "branch" => $dirnames{$d}, |
| 221 | + "executable" => $executable, |
| 222 | + "benchmark" => $shorttests{$t} . " " . read_descr("$resultsdir/$t.descr"), |
| 223 | + "environment" => $environment, |
| 224 | + "result_value" => $result_value, |
| 225 | + ); |
| 226 | + push @data, \%vals; |
| 227 | + } |
| 228 | + } |
| 229 | + |
| 230 | + print to_json(\@data, {utf8 => 1, pretty => 1}), "\n"; |
| 231 | +} |
| 232 | + |
177 | 233 | binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
|
178 | 234 |
|
179 |
| -print_default_results(); |
| 235 | +if ($codespeed) { |
| 236 | + print_codespeed_results($results_section); |
| 237 | +} else { |
| 238 | + print_default_results(); |
| 239 | +} |
0 commit comments