PerlStone2015/revcomp.pm

filter: Statementstmt 40.4% 19 / 47 Branchbran 0.0% 0 / 20 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 55.5% 5 / 9 Podpod 0.0% 0 / 3 totaltotal 30.3% 24 / 79 CC 11 SCAR 29.3
CC
11
Cov
28%
run
42.0
main
20.0
print_reverse
6.1
CRAP 18.8
« PerlStone2015/01overview.pm ↑ Summary PerlStone2015/spectralnorm.pm »
1 package Benchmark::Perl::Formance::Plugin::PerlStone2015::revcomp;
2 1 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark - Read DNA sequences - write their reverse-complement
4 1 $Benchmark::Perl::Formance::Plugin::PerlStone2015::revcomp::VERSION = '0.002';
5 # COMMAND LINE:
6 # /usr/bin/perl revcomp.perl-4.perl 0 < revcomp-input25000000.txt
7  
8 # The Computer Language Benchmarks Game
9 # http://shootout.alioth.debian.org/
10 #
11 # Contributed by Andrew Rodland
12 # Benchmark::Perl::Formance plugin by Steffen Schwigon
13  
14 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 #############################################################
17 # #
18 # Benchmark Code ahead - Don't touch without strong reason! #
19 # #
20 #############################################################
21  
22 1 ▶use File::ShareDir qw(dist_dir);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 1 ▶use Scalar::Util "reftype";
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26  
27 1 our $PRINT = 0;
28  
29 0 ▶sub print_reverse {
Subroutine print_reverse: not called CC=3 SCAR=18.1
Pod undocumented
30 1 ▶ no warnings 'uninitialized'; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
31 0 ▶ while (my $chunk = substr $_[0], -60, 60, '') {
Branch: 1 branch
BranchTrueFalseTotal
if (my $chunk = substr($_[0], -60, 60, "")) 0 0 0
32 0 my $dummy = scalar reverse($chunk);
33 0 ▶ print $dummy, "\n" if $PRINT;
Branch: 1 branch
BranchTrueFalseTotal
if $Benchmark::Perl::Formance::Plugin::PerlStone2015::revcomp::PRINT 0 0 0
34 }
35 }
36  
37 sub run
38 0 ▶{
Subroutine run: not called CC=6 SCAR=37.4
Pod undocumented
39 0 my ($infile) = @_;
40  
41 0 my $data;
42  
43 0 my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/Shootout" };
44 0 ▶ return { failed => "no Benchmark-Perl-Formance-Cargo" } if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
45  
46 0 my $srcfile = "$srcdir/$infile";
47 0 ▶ open my $INFILE, "<", $srcfile or return { failed => "Cannot read $srcfile" };
Branch: 1 branch
BranchTrueFalseTotal
open my $INFILE, "<", $srcfile or return {"failed", "Cannot read $srcfile"} 0 0 0
48  
49 0 ▶ while (<$INFILE>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $INFILE)) 0 0 0
50 0 ▶ if (/^>/) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^>/) { } 0 0 0
51 0 print_reverse $data;
52 0 ▶ print if $PRINT;
Branch: 1 branch
BranchTrueFalseTotal
if $Benchmark::Perl::Formance::Plugin::PerlStone2015::revcomp::PRINT 0 0 0
53 } else {
54 0 chomp;
55 0 tr{wsatugcyrkmbdhvnATUGCYRKMBDHVN}
56 {WSTAACGRYMKVHDBNTAACGRYMKVHDBN};
57 0 $data .= $_;
58 }
59 }
60 0 close $INFILE;
61 0 print_reverse $data;
62 }
63  
64 sub main
65 0 ▶{
Subroutine main: not called CC=4 SCAR=30.0
Pod undocumented
66 0 my ($options) = @_;
67  
68 0 $PRINT = $options->{D}{Shootout_revcomp_print};
69 0 ▶ my $goal = $options->{fastmode} ? "fasta-1000000.txt" : "fasta-1000000.txt";
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
70 0 ▶ my $count = $options->{fastmode} ? 1 : 5;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
71  
72 0 my $result;
73 0 ▶ my $t = timeit $count, sub { $result = run($goal) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
74 0 ▶ return $result if $result->{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $result->{"failed"} 0 0 0
75  
76 return {
77 0 Benchmark => $t,
78 goal => $goal,
79 count => $count,
80 result => $result,
81 };
82 }
83  
84 1 1;
85  
86 __END__
« PerlStone2015/01overview.pm ↑ Summary PerlStone2015/spectralnorm.pm »