blib/lib/Benchmark/Perl/Formance/Plugin/P6STD.pm

filter: Statementstmt 38.2% 26 / 68 Branchbran 0.0% 0 / 26 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 58.3% 7 / 12 Podpod 0.0% 0 / 3 totaltotal 25.5% 33 / 129 CC 18 SCAR 38.0
CC
18
Cov
25%
prepare
90.0
viv
56.0
main
20.0
CRAP 44.6
« blib/lib/Benchmark/Perl/Formance/Plugin/PerlCritic.pm ↑ Summary blib/lib/Benchmark/Perl/Formance.pm »
1 package Benchmark::Perl::Formance::Plugin::P6STD;
2 1 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark plugin - P6STD - Stress using Perl6/Perl5 tools around STD.pm
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = "0.002";
9  
10 #############################################################
11 # #
12 # Benchmark Code ahead - Don't touch without strong reason! #
13 # #
14 #############################################################
15  
16 1 our $goal;
17 1 our $count;
18  
19 1 ▶use Benchmark ':all', ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use File::Temp qw(tempfile tempdir);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use File::ShareDir qw(dist_dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use File::Copy::Recursive qw(dircopy fcopy);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 0 ▶sub prepare {
Subroutine prepare: not called CC=9 SCAR=45.0
Pod undocumented
26 0 my ($options) = @_;
27  
28 0 my $dstdir = tempdir( CLEANUP => 1 );
29  
30 0 my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/P6STD" };
31 0 ▶ return if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
32  
33 0 ▶ print STDERR "# Make viv in $dstdir ...\n" if $options->{verbose} >= 3;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} >= 3 0 0 0
34 0 dircopy($srcdir, $dstdir);
35  
36 0 my $cmd = "cd $dstdir ; make PERL=$^X 2>&1";
37 0 ▶ print STDERR "# $cmd\n" if $options->{verbose} && $options->{verbose} >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} and $options->{"verbose"} >= 4 0 0 0
Condition0%0/3
$options->{"verbose"} and $options->{"verbose"} >= 4
!ll&&!rl&&r
000
MC/DC0%0/2
$options->{"verbose"} and $options->{"verbose"} >= 4
$options->{"verbose"} $options->{"verbose"} >= 4
Truth table0%0/3
A and B
A= $options->{"verbose"}B= $options->{"verbose"} >= 4
ABresult
0X0
100
111
38 0 ▶ print STDERR "# Run...\n" if $options->{verbose} && $options->{verbose} >= 3;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} and $options->{"verbose"} >= 3 0 0 0
Condition0%0/3
$options->{"verbose"} and $options->{"verbose"} >= 3
!ll&&!rl&&r
000
MC/DC0%0/2
$options->{"verbose"} and $options->{"verbose"} >= 3
$options->{"verbose"} $options->{"verbose"} >= 3
Truth table0%0/3
A and B
A= $options->{"verbose"}B= $options->{"verbose"} >= 3
ABresult
0X0
100
111
39  
40 0 my @output;
41 0 ▶ my $makeviv = { Benchmark => timeit(1, sub { @output = map { chomp; $_ } qx"$cmd" }) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
42  
43 0 ▶ my $maxerr = ($#output < 10) ? $#output : 10;
Branch: 1 branch
BranchTrueFalseTotal
$#output < 10 ? : 0 0 0
44 0 ▶ print STDERR join("\n# ", "", @output[0..$maxerr]) if $options->{verbose} >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} >= 4 0 0 0
45  
46 0 return $dstdir, $makeviv;
47 }
48  
49 sub viv
50 0 ▶{
Subroutine viv: not called CC=7 SCAR=40.3
Pod undocumented
51 0 my ($workdir, $options) = @_;
52  
53 0 my $viv = "$workdir/viv";
54 0 my $perl6file = "$workdir/$goal";
55 0 my $cmd = "cd $workdir ; $^X -I. $viv $perl6file";
56  
57 0 ▶ print STDERR "# $cmd\n" if $options->{verbose} && $options->{verbose} >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} and $options->{"verbose"} >= 4 0 0 0
Condition0%0/3
$options->{"verbose"} and $options->{"verbose"} >= 4
!ll&&!rl&&r
000
MC/DC0%0/2
$options->{"verbose"} and $options->{"verbose"} >= 4
$options->{"verbose"} $options->{"verbose"} >= 4
Truth table0%0/3
A and B
A= $options->{"verbose"}B= $options->{"verbose"} >= 4
ABresult
0X0
100
111
58 0 ▶ print STDERR "# Run...\n" if $options->{verbose} && $options->{verbose} >= 3;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} and $options->{"verbose"} >= 3 0 0 0
Condition0%0/3
$options->{"verbose"} and $options->{"verbose"} >= 3
!ll&&!rl&&r
000
MC/DC0%0/2
$options->{"verbose"} and $options->{"verbose"} >= 3
$options->{"verbose"} $options->{"verbose"} >= 3
Truth table0%0/3
A and B
A= $options->{"verbose"}B= $options->{"verbose"} >= 3
ABresult
0X0
100
111
59  
60 0 my @output;
61 0 ▶ my $t = timeit ($count, sub { @output = map { chomp; $_ } qx"$cmd" });
Subroutine __ANON__: not called CC=1 SCAR=6.9
62  
63 0 ▶ my $maxerr = ($#output < 10) ? $#output : 10;
Branch: 1 branch
BranchTrueFalseTotal
$#output < 10 ? : 0 0 0
64 0 ▶ print STDERR join("\n# ", "", @output[0..$maxerr]) if $options->{verbose} >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} >= 4 0 0 0
65  
66 return {
67 0 Benchmark => $t,
68 goal => $goal,
69 };
70 }
71  
72 0 ▶sub main {
Subroutine main: not called CC=4 SCAR=30.0
Pod undocumented
73 0 my ($options) = @_;
74  
75 0 ▶ $goal = $options->{fastmode} ? "hello.p6" : "STD.pm6";
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
76 0 ▶ $count = $options->{fastmode} ? 1 : 5;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
77  
78 0 my $workdir;
79 my $makeviv;
80 0 my $viv;
81 0 ($workdir, $makeviv ) = prepare($options);
82 0 ▶ return { failed => "no Benchmark-Perl-Formance-Cargo" } if not $workdir;
Branch: 1 branch
BranchTrueFalseTotal
unless $workdir 0 0 0
83  
84 0 $viv = viv($workdir, $options);
85  
86 return {
87 0 makeviv => $makeviv,
88 viv => $viv,
89 };
90 }
91  
92 1 1;
93  
94 __END__
« blib/lib/Benchmark/Perl/Formance/Plugin/PerlCritic.pm ↑ Summary blib/lib/Benchmark/Perl/Formance.pm »