This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Porting/bench.pl: allow more than one file to be read at a go
authorYves Orton <demerphq@gmail.com>
Thu, 23 Mar 2017 21:06:51 +0000 (22:06 +0100)
committerYves Orton <demerphq@gmail.com>
Fri, 2 Jun 2017 12:51:02 +0000 (14:51 +0200)
Porting/bench.pl

index efff214..840d723 100755 (executable)
@@ -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};
+                }
+            }
         }
     }