Merge branch 'cc/perf-aggregate' into next
authorJunio C Hamano <gitster@pobox.com>
Thu, 8 Feb 2018 23:08:28 +0000 (15:08 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Feb 2018 23:08:28 +0000 (15:08 -0800)
"make perf" enhancement.

* cc/perf-aggregate:
perf/aggregate: sort JSON fields in output
perf/aggregate: add --reponame option
perf/aggregate: add --subsection option

1  2 
t/perf/aggregate.perl
diff --combined t/perf/aggregate.perl
index 3a0917fa61ef6e630ca4dc2bb28c2af671f98804,749d6689f95f7080a99e8849d1b3c35efe8750cc..821cf1498b78bbb5b43b2bda32bbcc88d580c31b
@@@ -1,6 -1,6 +1,6 @@@
  #!/usr/bin/perl
  
 -use lib '../../perl/blib/lib';
 +use lib '../../perl/build/lib';
  use strict;
  use warnings;
  use JSON;
@@@ -36,7 -36,8 +36,8 @@@ sub format_times 
        return $out;
  }
  
- my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests, $codespeed);
+ my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests,
+     $codespeed, $subsection, $reponame);
  while (scalar @ARGV) {
        my $arg = $ARGV[0];
        my $dir;
                shift @ARGV;
                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 "--";
        if (! -d $arg) {
                my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
@@@ -76,10 -95,15 +95,15 @@@ if (not @tests) 
  }
  
  my $resultsdir = "test-results";
- my $results_section = "";
- if (exists $ENV{GIT_PERF_SUBSECTION} and $ENV{GIT_PERF_SUBSECTION} ne "") {
-       $resultsdir .= "/" . $ENV{GIT_PERF_SUBSECTION};
-       $results_section = $ENV{GIT_PERF_SUBSECTION};
+ if (! $subsection and
+     exists $ENV{GIT_PERF_SUBSECTION} and
+     $ENV{GIT_PERF_SUBSECTION} ne "") {
+       $subsection = $ENV{GIT_PERF_SUBSECTION};
+ }
+ if ($subsection) {
+       $resultsdir .= "/" . $subsection;
  }
  
  my @subtests;
@@@ -183,19 -207,21 +207,21 @@@ sub print_default_results 
  }
  
  sub print_codespeed_results {
-       my ($results_section) = @_;
+       my ($subsection) = @_;
  
        my $project = "Git";
  
        my $executable = `uname -s -m`;
        chomp $executable;
  
-       if ($results_section ne "") {
-               $executable .= ", " . $results_section;
+       if ($subsection) {
+               $executable .= ", " . $subsection;
        }
  
        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};
        } elsif (exists $ENV{GIT_TEST_INSTALLED} and $ENV{GIT_TEST_INSTALLED} ne "") {
                $environment = $ENV{GIT_TEST_INSTALLED};
                }
        }
  
-       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: $!";
  
  if ($codespeed) {
-       print_codespeed_results($results_section);
+       print_codespeed_results($subsection);
  } else {
        print_default_results();
  }