Skip to content

Commit 9b6734e

Browse files
committed
Merge branch 'cc/perf-aggregate'
"make perf" enhancement. * cc/perf-aggregate: perf/aggregate: sort JSON fields in output perf/aggregate: add --reponame option perf/aggregate: add --subsection option
2 parents bfc817d + ed103ed commit 9b6734e

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

t/perf/aggregate.perl

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ sub format_times {
3636
return $out;
3737
}
3838

39-
my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests, $codespeed);
39+
my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
40+
$codespeed, $subsection, $reponame);
4041
while (scalar @ARGV) {
4142
my $arg = $ARGV[0];
4243
my $dir;
@@ -45,6 +46,24 @@ sub format_times {
4546
shift @ARGV;
4647
next;
4748
}
49+
if ($arg eq "--subsection") {
50+
shift @ARGV;
51+
$subsection = $ARGV[0];
52+
shift @ARGV;
53+
if (! $subsection) {
54+
die "empty subsection";
55+
}
56+
next;
57+
}
58+
if ($arg eq "--reponame") {
59+
shift @ARGV;
60+
$reponame = $ARGV[0];
61+
shift @ARGV;
62+
if (! $reponame) {
63+
die "empty reponame";
64+
}
65+
next;
66+
}
4867
last if -f $arg or $arg eq "--";
4968
if (! -d $arg) {
5069
my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
@@ -76,10 +95,15 @@ sub format_times {
7695
}
7796

7897
my $resultsdir = "test-results";
79-
my $results_section = "";
80-
if (exists $ENV{GIT_PERF_SUBSECTION} and $ENV{GIT_PERF_SUBSECTION} ne "") {
81-
$resultsdir .= "/" . $ENV{GIT_PERF_SUBSECTION};
82-
$results_section = $ENV{GIT_PERF_SUBSECTION};
98+
99+
if (! $subsection and
100+
exists $ENV{GIT_PERF_SUBSECTION} and
101+
$ENV{GIT_PERF_SUBSECTION} ne "") {
102+
$subsection = $ENV{GIT_PERF_SUBSECTION};
103+
}
104+
105+
if ($subsection) {
106+
$resultsdir .= "/" . $subsection;
83107
}
84108

85109
my @subtests;
@@ -183,19 +207,21 @@ sub print_default_results {
183207
}
184208

185209
sub print_codespeed_results {
186-
my ($results_section) = @_;
210+
my ($subsection) = @_;
187211

188212
my $project = "Git";
189213

190214
my $executable = `uname -s -m`;
191215
chomp $executable;
192216

193-
if ($results_section ne "") {
194-
$executable .= ", " . $results_section;
217+
if ($subsection) {
218+
$executable .= ", " . $subsection;
195219
}
196220

197221
my $environment;
198-
if (exists $ENV{GIT_PERF_REPO_NAME} and $ENV{GIT_PERF_REPO_NAME} ne "") {
222+
if ($reponame) {
223+
$environment = $reponame;
224+
} elsif (exists $ENV{GIT_PERF_REPO_NAME} and $ENV{GIT_PERF_REPO_NAME} ne "") {
199225
$environment = $ENV{GIT_PERF_REPO_NAME};
200226
} elsif (exists $ENV{GIT_TEST_INSTALLED} and $ENV{GIT_TEST_INSTALLED} ne "") {
201227
$environment = $ENV{GIT_TEST_INSTALLED};
@@ -227,13 +253,13 @@ sub print_codespeed_results {
227253
}
228254
}
229255

230-
print to_json(\@data, {utf8 => 1, pretty => 1}), "\n";
256+
print to_json(\@data, {utf8 => 1, pretty => 1, canonical => 1}), "\n";
231257
}
232258

233259
binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
234260

235261
if ($codespeed) {
236-
print_codespeed_results($results_section);
262+
print_codespeed_results($subsection);
237263
} else {
238264
print_default_results();
239265
}

0 commit comments

Comments
 (0)