summaryrefslogtreecommitdiff
path: root/t/perf/aggregate.perl
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2018-01-05 09:12:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-01-05 20:31:07 (GMT)
commit05eb1c37ed345d0ea244a239dad18de830e022f6 (patch)
tree7e02a6643b3384b7ec1dfe870d51adc77aaa8027 /t/perf/aggregate.perl
parent30ffff6ee24d1e9ee9c28d1c9d6e68725e0c2699 (diff)
downloadgit-05eb1c37ed345d0ea244a239dad18de830e022f6.zip
git-05eb1c37ed345d0ea244a239dad18de830e022f6.tar.gz
git-05eb1c37ed345d0ea244a239dad18de830e022f6.tar.bz2
perf/aggregate: implement codespeed JSON output
Codespeed (https://github.com/tobami/codespeed/) is an open source project that can be used to track how some software performs over time. It stores performance test results in a database and can show nice graphs and charts on a web interface. As it can be interesting to use Codespeed to see how Git performance evolves over time and releases, let's implement a Codespeed output in "perf/aggregate.perl". Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/perf/aggregate.perl')
-rwxr-xr-xt/perf/aggregate.perl64
1 files changed, 62 insertions, 2 deletions
diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
index 3609cb5..5c439f6 100755
--- a/t/perf/aggregate.perl
+++ b/t/perf/aggregate.perl
@@ -3,6 +3,7 @@
use lib '../../perl/blib/lib';
use strict;
use warnings;
+use JSON;
use Git;
sub get_times {
@@ -35,10 +36,15 @@ sub format_times {
return $out;
}
-my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests);
+my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests, $codespeed);
while (scalar @ARGV) {
my $arg = $ARGV[0];
my $dir;
+ if ($arg eq "--codespeed") {
+ $codespeed = 1;
+ shift @ARGV;
+ next;
+ }
last if -f $arg or $arg eq "--";
if (! -d $arg) {
my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
@@ -70,8 +76,10 @@ 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};
}
my @subtests;
@@ -174,6 +182,58 @@ sub print_default_results {
}
}
+sub print_codespeed_results {
+ my ($results_section) = @_;
+
+ my $project = "Git";
+
+ my $executable = `uname -s -m`;
+ chomp $executable;
+
+ if ($results_section ne "") {
+ $executable .= ", " . $results_section;
+ }
+
+ my $environment;
+ if (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};
+ $environment =~ s|/bin-wrappers$||;
+ } else {
+ $environment = `uname -r`;
+ chomp $environment;
+ }
+
+ my @data;
+
+ for my $t (@subtests) {
+ for my $d (@dirs) {
+ my $commitid = $prefixes{$d};
+ $commitid =~ s/^build_//;
+ $commitid =~ s/\.$//;
+ my ($result_value, $u, $s) = get_times("$resultsdir/$prefixes{$d}$t.times");
+
+ my %vals = (
+ "commitid" => $commitid,
+ "project" => $project,
+ "branch" => $dirnames{$d},
+ "executable" => $executable,
+ "benchmark" => $shorttests{$t} . " " . read_descr("$resultsdir/$t.descr"),
+ "environment" => $environment,
+ "result_value" => $result_value,
+ );
+ push @data, \%vals;
+ }
+ }
+
+ print to_json(\@data, {utf8 => 1, pretty => 1}), "\n";
+}
+
binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
-print_default_results();
+if ($codespeed) {
+ print_codespeed_results($results_section);
+} else {
+ print_default_results();
+}