Skip to content

Commit b8957ae

Browse files
author
Geoffrey Broadwell
committed
Detect compiler versions at start of benchmark run
1 parent a57424c commit b8957ae

File tree

1 file changed

+47
-10
lines changed

1 file changed

+47
-10
lines changed

bench

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ my %COMPILERS = (
4141
dir => 'BENCH',
4242
f_run => [$VM{perl5} ],
4343
e_run => [$VM{perl5}, qw( -E )],
44+
show_ver => [$VM{perl5}, qw( -E say+$] )],
4445
},
4546
{
4647
name => 'p5.pl',
@@ -51,6 +52,7 @@ my %COMPILERS = (
5152
dir => 'BENCH/../Perlito',
5253
f_run => [$VM{perl5}, qw( -Ilib5 perlito5.pl -Isrc5/lib )],
5354
e_run => [$VM{perl5}, qw( -Ilib5 perlito5.pl -Isrc5/lib -e )],
55+
show_ver => [$VM{perl5}, qw( -Ilib5 perlito5.pl --version )],
5456
},
5557
{
5658
name => 'p5.js_node',
@@ -61,6 +63,7 @@ my %COMPILERS = (
6163
dir => 'BENCH/../Perlito',
6264
f_run => [$VM{node_js}, qw( perlito5.js -Isrc5/lib )],
6365
e_run => [$VM{node_js}, qw( perlito5.js -Isrc5/lib -e )],
66+
show_ver => [$VM{node_js}, qw( perlito5.js --version )],
6467
},
6568
{
6669
name => 'p5.js_v8',
@@ -71,6 +74,7 @@ my %COMPILERS = (
7174
dir => 'BENCH/../Perlito',
7275
f_compile => [$VM{v8}, qw( perlito5.js -- -Isrc5/lib -Cjs )],
7376
e_compile => [$VM{v8}, qw( perlito5.js -- -Isrc5/lib -Cjs -e )],
77+
show_ver => [$VM{v8}, qw( perlito5.js -- --version )],
7478
f_run => [$VM{v8}, qw( COMPILED -- )],
7579
e_run => [$VM{v8}, qw( COMPILED -- )],
7680
},
@@ -85,6 +89,7 @@ my %COMPILERS = (
8589
dir => 'BENCH/../rakudo',
8690
f_run => [qw( install/bin/perl6 )],
8791
e_run => [qw( install/bin/perl6 -e )],
92+
show_ver => [qw( install/bin/perl6 --version )],
8893
},
8994
{
9095
name => 'niecza',
@@ -95,6 +100,7 @@ my %COMPILERS = (
95100
dir => 'BENCH/../niecza',
96101
f_run => [$VM{mono}, qw( run/Niecza.exe )],
97102
e_run => [$VM{mono}, qw( run/Niecza.exe -e )],
103+
show_ver => [$VM{mono}, qw( run/Niecza.exe --version )],
98104
},
99105
{
100106
name => 'p6.pl',
@@ -105,6 +111,7 @@ my %COMPILERS = (
105111
dir => 'BENCH/../Perlito',
106112
f_compile => [$VM{perl5}, qw( -Ilib5 perlito6.pl -Cperl5 )],
107113
e_compile => [$VM{perl5}, qw( -Ilib5 perlito6.pl -Cperl5 -e )],
114+
show_ver => [$VM{perl5}, qw( -Ilib5 perlito6.pl --version )],
108115
f_run => [$VM{perl5}, qw( -Ilib5 COMPILED )],
109116
e_run => [$VM{perl5}, qw( -Ilib5 COMPILED )],
110117
},
@@ -117,6 +124,7 @@ my %COMPILERS = (
117124
dir => 'BENCH/../Perlito',
118125
f_compile => [$VM{v8}, qw( perlito6.js -- -Cjs )],
119126
e_compile => [$VM{v8}, qw( perlito6.js -- -Cjs -e )],
127+
show_ver => [$VM{v8}, qw( perlito6.js -- --version )],
120128
f_run => [$VM{v8}, qw( COMPILED -- )],
121129
e_run => [$VM{v8}, qw( COMPILED -- )],
122130
},
@@ -131,6 +139,7 @@ my %COMPILERS = (
131139
dir => 'BENCH/../nqp',
132140
f_run => [qw( install/bin/nqp --vmlibs=math_ops )],
133141
e_run => [qw( install/bin/nqp --vmlibs=math_ops -e )],
142+
show_ver => [qw( install/bin/nqp --version )],
134143
},
135144
{
136145
name => 'rakudo.nqp',
@@ -141,6 +150,7 @@ my %COMPILERS = (
141150
dir => 'BENCH/../rakudo',
142151
f_run => [qw( install/bin/perl6 )],
143152
e_run => [qw( install/bin/perl6 -e )],
153+
show_ver => [qw( install/bin/perl6 --version )],
144154
},
145155
{
146156
name => 'niecza.nqp',
@@ -151,6 +161,7 @@ my %COMPILERS = (
151161
dir => 'BENCH/../niecza',
152162
f_run => [$VM{mono}, qw( run/Niecza.exe )],
153163
e_run => [$VM{mono}, qw( run/Niecza.exe -e )],
164+
show_ver => [$VM{mono}, qw( run/Niecza.exe --version )],
154165
},
155166
],
156167
);
@@ -244,13 +255,11 @@ sub MAIN {
244255
tests => \%TESTS,
245256
);
246257

247-
my $bench_rev = `git describe --always --dirty`;
248-
chomp $bench_rev;
249-
my %run = (
250-
start_time => time,
251-
bench_rev => $bench_rev,
252-
options => \%opt,
253-
);
258+
my %run = (
259+
start_time => time,
260+
options => \%opt,
261+
versions => detect_versions(),
262+
);
254263

255264
# Run tests
256265
my (@results, $startup);
@@ -274,6 +283,34 @@ sub MAIN {
274283
$formatter->(\%config, \%run, \@results, $opt{style}, $out_fh);
275284
}
276285

286+
sub detect_versions {
287+
say "Detecting versions ...";
288+
289+
my %version;
290+
my $cwd = cwd;
291+
292+
for my $group (@GROUPS) {
293+
for my $compiler (@{$COMPILERS{$group}}) {
294+
next unless $compiler->{enabled};
295+
296+
my $dir = $compiler->{dir} || 'BENCH';
297+
my @cmd = @{$compiler->{show_ver}};
298+
s/\bBENCH\b/$FindBin::Bin/g for $dir, @cmd;
299+
300+
chdir $dir;
301+
$version{$compiler->{name}} = `@cmd`;
302+
}
303+
}
304+
305+
chdir $FindBin::Bin;
306+
$version{bench} = `git describe --always --dirty`;
307+
308+
chomp for values %version;
309+
310+
chdir $cwd;
311+
return \%version;
312+
}
313+
277314
sub run_tests {
278315
my ($test_type, $tests, $results, $startup) = @_;
279316

@@ -487,7 +524,7 @@ sub summarize_results_text {
487524

488525
my $start = friendly_time($run->{start_time});
489526
my $ignore = $run->{options}{'ignore-startup'} ? ' (ignoring startup time)' : '';
490-
my $output = "$CLEAR\n==> perl6-bench rev $run->{bench_rev} run at $start$ignore\n\n";
527+
my $output = "$CLEAR\n==> perl6-bench version $run->{versions}{bench} run at $start$ignore\n\n";
491528

492529
$output .= join($spacer => ' ' x $longest_test, @lang_titles) . "\n";
493530
$output .= sprintf "$format\n", '', @comp_names;
@@ -579,7 +616,7 @@ sub summarize_results_html_snippet {
579616
.bench_summary caption { font-style: italic; }
580617
.bench_summary td { padding-left: .4em; padding-right: .4em; }
581618
.bench_summary th { padding-left: .4em; padding-right: .4em; }
582-
.bench_rev { font-family: monospace; }
619+
.bench_ver { font-family: monospace; }
583620
.bench_start_time { font-family: monospace; }
584621
.bench_language { text-align: center; border-bottom: 1px solid #999; border-left: .4em solid #fff; border-right: .4em solid #fff; }
585622
.bench_compiler { text-align: center; padding-top: .1em; }
@@ -611,7 +648,7 @@ CSS
611648
612649
my $ignore = $run->{options}{'ignore-startup'} ? ' (ignoring startup time)' : '';
613650
$html .= qq{<table class="bench_summary" cellspacing="0" cellpadding="0">\n};
614-
$html .= qq{<caption>perl6-bench rev <span class="bench_rev">$run->{bench_rev}</span> run at <span class="bench_start_time">} . friendly_time($run->{start_time}) . qq{</span>$ignore</caption>\n};
651+
$html .= qq{<caption>perl6-bench version <span class="bench_ver">$run->{versions}{bench}</span> run at <span class="bench_start_time">} . friendly_time($run->{start_time}) . qq{</span>$ignore</caption>\n};
615652
$html .= "<tr><th></th>\n" . join('' => map qq{ <th class="bench_language" colspan="$lang_count{$_}">$_</th>\n} => @langs) . "</tr>\n";
616653
$html .= "<tr><th></th>\n" . join('' => map qq{ <th class="bench_compiler">$_</th>\n} => @comp_names) . "</tr>\n";
617654
$html .= "<tr><th>TEST</th>\n" . join('' => map qq{ <th class="bench_vm">$_</th>\n} => @vm_names) . "</tr>\n";

0 commit comments

Comments
 (0)