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>
Christian Couder committed
Jan 5, 2018 at 10:12 UTC
05eb1c37ed345d0ea244a239dad18de830e022f6
1 file changed
+62
-2
t/perf/aggregate.perl
+62
-2
@@ -3,6 +3,7 @@
3
use lib '../../perl/blib/lib';
4
use strict;
5
use warnings;
6
+use JSON;
7
use Git;
8
9
sub get_times {
@@ -35,10 +36,15 @@ sub format_times {
36
return $out;
37
}
38
38
-my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests);
39
+my (@dirs, %dirnames, %dirabbrevs, %prefixes, @tests, $codespeed);
40
while (scalar @ARGV) {
41
my $arg = $ARGV[0];
42
my $dir;
43
+ if ($arg eq "--codespeed") {
44
+ $codespeed = 1;
45
+ shift @ARGV;
46
+ next;
47
+ }
48
last if -f $arg or $arg eq "--";
49
if (! -d $arg) {
50
my $rev = Git::command_oneline(qw(rev-parse --verify), $arg);
@@ -70,8 +76,10 @@ if (not @tests) {
76
}
77
78
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};
83
}
84
85
my @subtests;
@@ -174,6 +182,58 @@ sub print_default_results {
182
}
183
}
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
+
233
binmode STDOUT, ":utf8" or die "PANIC on binmode: $!";
234
179
-print_default_results();
235
+if ($codespeed) {
236
+ print_codespeed_results($results_section);
237
+} else {
238
+ print_default_results();
239
+}