From ee172d48f1de7778c3811ec1c03e3fa788443c74 Mon Sep 17 00:00:00 2001 From: Yves Orton Date: Thu, 23 Mar 2017 22:06:51 +0100 Subject: [PATCH] Porting/bench.pl: allow more than one file to be read at a go --- Porting/bench.pl | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/Porting/bench.pl b/Porting/bench.pl index efff214..840d723 100755 --- a/Porting/bench.pl +++ b/Porting/bench.pl @@ -392,7 +392,7 @@ my %OPTS = ( 'norm=s' => \$OPTS{norm}, 'perlargs=s' => \$OPTS{perlargs}, 'raw' => \$OPTS{raw}, - 'read|r=s' => \$OPTS{read}, + 'read|r=s@' => \$OPTS{read}, 'show!' => \$OPTS{show}, 'sort=s' => \$OPTS{sort}, 'tests=s' => \$OPTS{tests}, @@ -679,25 +679,48 @@ sub do_grind { if $bisect_min > $bisect_max; } - if ($OPTS{read}) { - open my $in, '<:encoding(UTF-8)', $OPTS{read} - or die " Error: can't open '$OPTS{read}' for reading: $!\n"; + foreach my $file (@{$OPTS{read}}) { + open my $in, '<:encoding(UTF-8)', $file + or die " Error: can't open '$file' for reading: $!\n"; my $data = do { local $/; <$in> }; close $in; my $hash = JSON::PP::decode_json($data); if (int($FORMAT_VERSION) < int($hash->{version})) { die "Error: unsupported version $hash->{version} in file" - . "'$OPTS{read}' (too new)\n"; + . "'$file' (too new)\n"; } - ($loop_counts, $perls, $results, $tests, $order) = + my ($read_loop_counts, $read_perls, $read_results, $read_tests, $read_order) = @$hash{qw(loop_counts perls results tests order)}; + filter_tests($read_results); + filter_tests($read_tests); + if (!$read_order) { + $order = [ sort keys %$read_tests ]; + } + if (!$loop_counts) { + ($loop_counts, $perls, $results, $tests, $order) = + ($read_loop_counts, $read_perls, $read_results, $read_tests, $read_order); + filter_tests($results); + filter_tests($tests); + if (!$order) { + $order = [ sort keys %$tests ]; + } + } else { + my @have_keys= sort keys %$read_tests; + my @want_keys= sort keys %$tests; + + if ("@have_keys" ne "@want_keys" or + "@$read_loop_counts" ne "@$loop_counts") + { + die "tests run aren't the same, cant merge read files"; + } - filter_tests($results); - filter_tests($tests); - - if (!$order) { - $order = [ sort keys %$tests ]; + push @$perls, @{$hash->{perls}}; + foreach my $test (keys %{$hash->{results}}) { + foreach my $perl (keys %{$hash->{results}{$test}}) { + $results->{$test}{$perl}= $hash->{results}{$test}{$perl}; + } + } } } -- 1.8.3.1