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
This commit is contained in:
Junio C Hamano 2018-02-15 14:55:44 -08:00
commit 9b6734e510

View File

@ -36,7 +36,8 @@ sub format_times {
return $out; return $out;
} }
my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests, $codespeed); my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
$codespeed, $subsection, $reponame);
while (scalar @ARGV) { while (scalar @ARGV) {
my $arg = $ARGV[0]; my $arg = $ARGV[0];
my $dir; my $dir;
@ -45,6 +46,24 @@ while (scalar @ARGV) {
shift @ARGV; shift @ARGV;
next; next;
} }
if ($arg eq "--subsection") {
shift @ARGV;
$subsection = $ARGV[0];
shift @ARGV;
if (! $subsection) {
die "empty subsection";
}
next;
}
if ($arg eq "--reponame") {
shift @ARGV;
$reponame = $ARGV[0];
shift @ARGV;
if (! $reponame) {
die "empty reponame";
}
next;
}
last if -f $arg or $arg eq "--"; last if -f $arg or $arg eq "--";
if (! -d $arg) { if (! -d $arg) {
my $rev = Git::command_oneline(qw(rev-parse --verify), $arg); my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
@ -76,10 +95,15 @@ if (not @tests) {
} }
my $resultsdir = "test-results"; my $resultsdir = "test-results";
my $results_section = "";
if (exists $ENV{GIT_PERF_SUBSECTION} and $ENV{GIT_PERF_SUBSECTION} ne "") { if (! $subsection and
$resultsdir .= "/" . $ENV{GIT_PERF_SUBSECTION}; exists $ENV{GIT_PERF_SUBSECTION} and
$results_section = $ENV{GIT_PERF_SUBSECTION}; $ENV{GIT_PERF_SUBSECTION} ne "") {
$subsection = $ENV{GIT_PERF_SUBSECTION};
}
if ($subsection) {
$resultsdir .= "/" . $subsection;
} }
my @subtests; my @subtests;
@ -183,19 +207,21 @@ sub print_default_results {
} }
sub print_codespeed_results { sub print_codespeed_results {
my ($results_section) = @_; my ($subsection) = @_;
my $project = "Git"; my $project = "Git";
my $executable = `uname -s -m`; my $executable = `uname -s -m`;
chomp $executable; chomp $executable;
if ($results_section ne "") { if ($subsection) {
$executable .= ", " . $results_section; $executable .= ", " . $subsection;
} }
my $environment; my $environment;
if (exists $ENV{GIT_PERF_REPO_NAME} and $ENV{GIT_PERF_REPO_NAME} ne "") { if ($reponame) {
$environment = $reponame;
} elsif (exists $ENV{GIT_PERF_REPO_NAME} and $ENV{GIT_PERF_REPO_NAME} ne "") {
$environment = $ENV{GIT_PERF_REPO_NAME}; $environment = $ENV{GIT_PERF_REPO_NAME};
} elsif (exists $ENV{GIT_TEST_INSTALLED} and $ENV{GIT_TEST_INSTALLED} ne "") { } elsif (exists $ENV{GIT_TEST_INSTALLED} and $ENV{GIT_TEST_INSTALLED} ne "") {
$environment = $ENV{GIT_TEST_INSTALLED}; $environment = $ENV{GIT_TEST_INSTALLED};
@ -227,13 +253,13 @@ sub print_codespeed_results {
} }
} }
print to_json(\@data, {utf8 => 1, pretty => 1}), "\n"; print to_json(\@data, {utf8 => 1, pretty => 1, canonical => 1}), "\n";
} }
binmode STDOUT, ":utf8" or die "PANIC on binmode: $!"; binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
if ($codespeed) { if ($codespeed) {
print_codespeed_results($results_section); print_codespeed_results($subsection);
} else { } else {
print_default_results(); print_default_results();
} }