File Coverage

blib/lib/Parallel/parallel_map.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Parallel::parallel_map;
2              
3 97     97   2408510 use 5.008;
  97         388  
  97         5820  
4             our $VERSION = '0.02';
5              
6 97     97   679 use strict;
  97         194  
  97         8342  
7 97     97   582 use warnings;
  97         582  
  97         4074  
8 97     97   98261 use Parallel::DataPipe;
  97         3403051  
  97         15132  
9              
10             require Exporter;
11              
12             our @ISA = qw(Exporter);
13              
14             our @EXPORT = qw(parallel_map);
15              
16              
17             sub parallel_map(&@) {
18 342     342 0 713548 my ($code,@input) = @_;
19 342         1089 my (@result,@output);
20 342 100       2154 if (wantarray) {
21 325     30356   4033 @output = (output=>sub {my ($r,$i) = @_;$result[$i] = $r;});
  30356         21580119  
  30356         134742  
22             }
23             Parallel::DataPipe::run {
24 342         18297 input => \@input,
25             process => $code,
26             @output,
27             };
28 246 100       173076 return wantarray?@result:();
29             }
30              
31             1;
32              
33             __END__