« blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/regexdna.pm
↑ Summary
blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/revcomp.pm »
| 1 | package Benchmark::Perl::Formance::Plugin::RegexpCommonTS; | ||||||||||||||||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:SCHWIGON'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: benchmark plugin - RegexpCommonTS - RegexpCommon test suite as benchmark | ||||||||||||||||||||||||||||
| 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 | ▶ | use File::Temp qw(tempfile tempdir); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use File::Copy::Recursive qw(dircopy); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use File::ShareDir qw(dist_dir); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Time::HiRes qw(gettimeofday); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | our $count; | |||||||||||||||||||||||||||
| 22 | 1 | our $recurse; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Benchmark ':hireswallclock'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub prepare { | ||||||||||||||||||||||||||
|
Subroutine
prepare: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | my ($options) = @_; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | my $dstdir = tempdir( CLEANUP => 1 ); | |||||||||||||||||||||||||||
| 30 | 0 | my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/RegexpCommonTS" }; | |||||||||||||||||||||||||||
| 31 | 0 | ▶ | return if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | print STDERR "# Prepare cargo RegexpCommon testsuite in $dstdir ...\n" if $options->{verbose} >= 3; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | dircopy($srcdir, $dstdir); | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 0 | (my $prove = $^X) =~ s!/perl([\d.]*)$!/prove$1!; | |||||||||||||||||||||||||||
| 38 | 0 | ▶ | print STDERR "# Use prove: $prove\n" if $options->{verbose}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | return { | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | failed => "did not find executable prove", | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$prove and -x $prove
MC/DC0%0/2
$prove and -x $prove
$prove
-x $prove
Truth table0%0/3
A and B
A= $proveB= -x $prove
| |||||||||||||||||||||||||||||
| 42 | prove => $prove, | ||||||||||||||||||||||||||||
| 43 | } unless $prove && -x $prove; | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | return ($dstdir, $prove, $recurse); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub nonaggregated { | ||||||||||||||||||||||||||
|
Subroutine
nonaggregated: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 0 | my ($dstdir, $prove, $recurse, $options) = @_; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | my $cmd = "cd $dstdir ; $^X $prove $recurse '$dstdir/t' 2>&1"; | |||||||||||||||||||||||||||
| 52 | 0 | ▶ | print STDERR "# $cmd\n" if $options->{verbose} >= 4; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | print STDERR "# Run...\n" if $options->{verbose} >= 3; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | my @output; | |||||||||||||||||||||||||||
| 56 | 0 | ▶ | my $t = timeit $count, sub { @output = map { chomp; $_ } qx($cmd) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | my $maxerr = ($#output < 10) ? $#output : 10; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | ▶ | print STDERR join("\n# ", "", @output[0..$maxerr]) if $options->{verbose} >= 4; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | return { | ||||||||||||||||||||||||||||
| 62 | 0 | Benchmark => $t, | |||||||||||||||||||||||||||
| 63 | prove_path => $prove, | ||||||||||||||||||||||||||||
| 64 | count => $count, | ||||||||||||||||||||||||||||
| 65 | }; | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub main { | ||||||||||||||||||||||||||
|
Subroutine
main: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 0 | my ($options) = @_; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $count = $options->{fastmode} ? 1 : 5; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $recurse = $options->{fastmode} ? "" : "-r"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | my ($dstdir, $prove, $recurse) = prepare($options); | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | return { failed => "no Benchmark-Perl-Formance-Cargo" } if not $dstdir; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | return nonaggregated($dstdir, $prove, $recurse, $options); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 1 | 1; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||