Skip to content

Commit ee172d4

Browse files
committed
Porting/bench.pl: allow more than one file to be read at a go
1 parent 8ef5f06 commit ee172d4

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

Porting/bench.pl

+34-11
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ sub usage {
392392
'norm=s' => \$OPTS{norm},
393393
'perlargs=s' => \$OPTS{perlargs},
394394
'raw' => \$OPTS{raw},
395-
'read|r=s' => \$OPTS{read},
395+
'read|r=s@' => \$OPTS{read},
396396
'show!' => \$OPTS{show},
397397
'sort=s' => \$OPTS{sort},
398398
'tests=s' => \$OPTS{tests},
@@ -679,25 +679,48 @@ sub do_grind {
679679
if $bisect_min > $bisect_max;
680680
}
681681

682-
if ($OPTS{read}) {
683-
open my $in, '<:encoding(UTF-8)', $OPTS{read}
684-
or die " Error: can't open '$OPTS{read}' for reading: $!\n";
682+
foreach my $file (@{$OPTS{read}}) {
683+
open my $in, '<:encoding(UTF-8)', $file
684+
or die " Error: can't open '$file' for reading: $!\n";
685685
my $data = do { local $/; <$in> };
686686
close $in;
687687

688688
my $hash = JSON::PP::decode_json($data);
689689
if (int($FORMAT_VERSION) < int($hash->{version})) {
690690
die "Error: unsupported version $hash->{version} in file"
691-
. "'$OPTS{read}' (too new)\n";
691+
. "'$file' (too new)\n";
692692
}
693-
($loop_counts, $perls, $results, $tests, $order) =
693+
my ($read_loop_counts, $read_perls, $read_results, $read_tests, $read_order) =
694694
@$hash{qw(loop_counts perls results tests order)};
695+
filter_tests($read_results);
696+
filter_tests($read_tests);
697+
if (!$read_order) {
698+
$order = [ sort keys %$read_tests ];
699+
}
700+
if (!$loop_counts) {
701+
($loop_counts, $perls, $results, $tests, $order) =
702+
($read_loop_counts, $read_perls, $read_results, $read_tests, $read_order);
703+
filter_tests($results);
704+
filter_tests($tests);
705+
if (!$order) {
706+
$order = [ sort keys %$tests ];
707+
}
708+
} else {
709+
my @have_keys= sort keys %$read_tests;
710+
my @want_keys= sort keys %$tests;
711+
712+
if ("@have_keys" ne "@want_keys" or
713+
"@$read_loop_counts" ne "@$loop_counts")
714+
{
715+
die "tests run aren't the same, cant merge read files";
716+
}
695717

696-
filter_tests($results);
697-
filter_tests($tests);
698-
699-
if (!$order) {
700-
$order = [ sort keys %$tests ];
718+
push @$perls, @{$hash->{perls}};
719+
foreach my $test (keys %{$hash->{results}}) {
720+
foreach my $perl (keys %{$hash->{results}{$test}}) {
721+
$results->{$test}{$perl}= $hash->{results}{$test}{$perl};
722+
}
723+
}
701724
}
702725
}
703726

0 commit comments

Comments
 (0)