« 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
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | print STDERR "# Make viv in $dstdir ...\n" if $options->{verbose} >= 3; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$options->{"verbose"} and $options->{"verbose"} >= 4
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
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | print STDERR "# Run...\n" if $options->{verbose} && $options->{verbose} >= 3; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options->{"verbose"} and $options->{"verbose"} >= 3
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | print STDERR join("\n# ", "", @output[0..$maxerr]) if $options->{verbose} >= 4; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$options->{"verbose"} and $options->{"verbose"} >= 4
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
| |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | print STDERR "# Run...\n" if $options->{verbose} && $options->{verbose} >= 3; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options->{"verbose"} and $options->{"verbose"} >= 3
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | print STDERR join("\n# ", "", @output[0..$maxerr]) if $options->{verbose} >= 4; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $count = $options->{fastmode} ? 1 : 5; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||