Skip to content

Commit bc258b6

Browse files
author
Geoffrey Broadwell
committed
Add --skip-incomplete option for analyze
Skips test results that have data for some compilers and not others when computing summary scores; this allows comparison of compilers that didn't all complete every test successfully. This option is defaulted on by `bench compare` and `bench history`.
1 parent 0923c8d commit bc258b6

File tree

3 files changed

+41
-13
lines changed

3 files changed

+41
-13
lines changed

analyze

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ sub process_options_and_arguments {
4848
GetOptions(\%opt, 'help|h|?!', 'man!', 'format=s', 'style=s', 'outfile=s',
4949
'ignore-startup|ignore_startup|ignorestartup!',
5050
'ignore-compile|ignore_compile|ignorecompile!',
51+
'skip-incomplete|skip_incomplete|skipincomplete!',
5152
'compare!', 'history!')
5253
or pod2usage(-verbose => 0);
5354
pod2usage(-verbose => 1) if $opt{help};
@@ -76,8 +77,10 @@ sub process_options_and_arguments {
7677
sub analyze_timings_files {
7778
my ($opt, $out_fh, @files) = @_;
7879

79-
my $ignore_startup = $opt->{'ignore-startup'};
80-
my $ignore_compile = $opt->{'ignore-compile'};
80+
my $ignore_startup = $opt->{'ignore-startup'};
81+
my $ignore_compile = $opt->{'ignore-compile'};
82+
my $skip_incomplete = $opt->{'skip-incomplete'};
83+
8184
my $analyze_timing_data = sub {
8285
my $data = shift;
8386
my $startup = $data->{run}{startup} || {};
@@ -87,7 +90,7 @@ sub analyze_timings_files {
8790
$ignore_startup,
8891
$ignore_compile);
8992
}
90-
$data->{score} = compute_scores($data);
93+
$data->{score} = compute_scores($data, $skip_incomplete);
9194

9295
$opt->{formatter}->($data, $opt, $out_fh);
9396
};
@@ -261,7 +264,7 @@ sub compare_scaled_times {
261264
# Compute overall 'score' by geometric mean of relative rates to
262265
# a standard compiler serving as the reference 1.0 value.
263266
sub compute_scores {
264-
my $data = shift;
267+
my ($data, $skip_incomplete) = @_;
265268
my $tests = $data->{times};
266269

267270
my @compilers = map { $_->{key} } @{$data->{config}{compilers}};
@@ -270,11 +273,19 @@ sub compute_scores {
270273
my %score;
271274
$score{$_} = 1.0 for @compilers;
272275

273-
for my $test (@$tests) {
276+
TEST: for my $test (@$tests) {
274277
my $peak_rate = $test->{compare}{peak_rate};
275-
my $reference = $peak_rate->{$standard}{rate};
278+
279+
# Optionally skip any test that doesn't have a peak rate
280+
# specified for every compiler being compared
281+
if ($skip_incomplete) {
282+
for my $compiler (@compilers) {
283+
next TEST unless defined $peak_rate->{$compiler}{rate};
284+
}
285+
}
276286

277287
# Can't compute scores at all if we lack a reference point
288+
my $reference = $peak_rate->{$standard}{rate};
278289
return unless $reference;
279290

280291
for my $compiler (@compilers) {
@@ -456,8 +467,9 @@ sub summarize_results_text_history {
456467
my $ignore = @ignore ? ' (ignoring ' . join(' and ' => @ignore) . ')' : '';
457468
my $start = friendly_time($data->{run}{start_time});
458469
my $run_at = $opt->{compare} ? '' : " run at $start";
470+
my $skip = $opt->{'skip-incomplete'} ? ' (skipping incomplete data)' : '';
459471
my $output = "$CLEAR\n==> perl6-bench version $data->{run}{versions}{bench}$run_at$ignore\n";
460-
$output .= "--- showing HISTORICAL SCORES\n\n";
472+
$output .= "--- showing HISTORICAL SCORES$skip\n\n";
461473
$output .= sprintf $format, 'DATE', @comp_names;
462474

463475
# Put scores into columns by compiler name, allowing multiple scores
@@ -580,7 +592,7 @@ CSS
580592
my $ignore = @ignore ? ' (ignoring ' . join(' and ' => @ignore) . ')' : '';
581593
my $run_at = $opt->{compare} ? '' : qq{ run at <span class="bench_start_time">} . friendly_time($data->{run}{start_time}) . qq{</span>};
582594
my $showing = 'showing ' . english_list(@{$s->{showing}});
583-
$showing =~ s/\((.+?)\)/(<strong>$1<\/strong>)/g;
595+
$showing =~ s/\((\S+?)\)/(<strong>$1<\/strong>)/g;
584596
585597
$html .= qq{<table class="bench_summary" cellspacing="0" cellpadding="0">\n};
586598
$html .= qq{<caption>perl6-bench version <span class="bench_ver">$data->{run}{versions}{bench}</span>$run_at$ignore<br>$showing</caption>\n};
@@ -1100,7 +1112,7 @@ analyze -- Analyze benchmark data produced by timeall
11001112
analyze [--help|-h|-?] [--man]
11011113
[--format=text|json|html|html_snippet|html_plot]
11021114
[--style=0|1|auto] [--outfile=path/to/file.ext]
1103-
[--ignore-startup] [--ignore-compile]
1115+
[--ignore-startup] [--ignore-compile] [--skip-incomplete]
11041116
[--compare] [--history]
11051117
path/to/timing_file.json [path/to/second_timing_file.json ...]
11061118
@@ -1168,6 +1180,15 @@ itself from each benchmark result, so that runtime performance can be
11681180
compared more directly. Only works for scalable tests, because it uses
11691181
runtime at C<SCALE = 0> as a portable proxy for true compile time.
11701182
1183+
=item --skip-incomplete
1184+
1185+
When computing summary scores, skip any incomplete test data (tests that
1186+
have timing data for some compilers but not others). This enables summary
1187+
comparison of compilers that can't all complete every test. This can occur
1188+
because of bugs, old versions of compilers that don't support current syntax,
1189+
or compilers/languages that lack certain language features (NQP being the
1190+
most common example of this).
1191+
11711192
=item --compare
11721193
11731194
When processing multiple timing files, compare times across all timing files

bench

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,12 @@ multi MAIN ('time', *@components, :$variants?, :$tests?, :$tests-tagged?,
357357

358358
#= Compare benchmark timings
359359
multi MAIN ('compare', *@timings, :$format?, :$style?, :$outfile?,
360-
Bool :$ignore-startup = True, Bool :$ignore-compile = True) {
360+
Bool :$ignore-startup = True, Bool :$ignore-compile = True,
361+
Bool :$skip-incomplete = True) {
361362
needs-timings('compare');
362363

363-
my @options = as-options(:compare, :$ignore-startup, :$ignore-compile, :$format, :$style, :$outfile);
364+
my @options = as-options(:compare, :$ignore-startup, :$ignore-compile,
365+
:$skip-incomplete, :$format, :$style, :$outfile);
364366

365367
my @timings-files;
366368
for explode-timings(@timings, :!chdir).kv -> $component, @files {
@@ -372,11 +374,13 @@ multi MAIN ('compare', *@timings, :$format?, :$style?, :$outfile?,
372374

373375
#= Compare historical peak performance scores
374376
multi MAIN ('history', *@timings, :$format?, :$style?, :$outfile?,
375-
Bool :$ignore-startup = True, Bool :$ignore-compile = True) {
377+
Bool :$ignore-startup = True, Bool :$ignore-compile = True,
378+
Bool :$skip-incomplete = True) {
376379
needs-timings('show history');
377380

378381
my @options = as-options(:compare, :history,
379382
:$ignore-startup, :$ignore-compile,
383+
:$skip-incomplete,
380384
:$format, :$style, :$outfile);
381385

382386
my @timings-files;

lib/Analyze/Summary.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ sub init {
7474

7575
my @showing = ('PEAK RATE (/s)');
7676
push @showing, 'TIMES SLOWER THAN FASTEST (x)' if $o->{compare};
77-
push @showing, 'SUMMARY SCORES' if $d->{score};
77+
if ($d->{score}) {
78+
my $skip = $o->{'skip-incomplete'} ? ' (skipping incomplete data)' : '';
79+
push @showing, "SUMMARY SCORES$skip";
80+
}
7881
$s->{showing} = \@showing;
7982

8083
return $s;

0 commit comments

Comments
 (0)