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

filter: Statementstmt 49.0% 26 / 53 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 1 totaltotal 39.2% 33 / 84 CC 11 SCAR 43.4
CC
11
Cov
36%
main
132.0
__ANON__
2.0
BEGIN
1.0
CRAP 76.9
↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/PerlCritic.pm »
1 package Benchmark::Perl::Formance::Plugin::SpamAssassin;
2 1 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark plugin - SpamAssassin - SpamAssassin Benchmarks
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.003";
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 $easy_ham;
23  
24 1 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 0 ▶sub main {
Subroutine main: not called CC=11 SCAR=48.8
Pod undocumented
27 0 my ($options) = @_;
28  
29 0 require Mail::SpamAssassin;
30 0 my $sa_version = $Mail::SpamAssassin::VERSION;
31  
32 0 my $srcdir; eval { $srcdir = dist_dir('Benchmark-Perl-Formance-Cargo')."/SpamAssassin" };
33 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
34 0 return { salearn => { failed => "no Benchmark-Perl-Formance-Cargo" } }
35 }
36  
37 0 (my $salearn = $^X) =~ s!/perl[\d.]*$!/sa-learn!;
38 0 ▶ if (not $salearn && -x $salearn) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($salearn and -x $salearn) 0 0 0
Condition0%0/3
$salearn and -x $salearn
!ll&&!rl&&r
000
MC/DC0%0/2
$salearn and -x $salearn
$salearn -x $salearn
Truth table0%0/3
A and B
A= $salearnB= -x $salearn
ABresult
0X0
100
111
39 0 ▶ print STDERR "# did not find executable $salearn\n" if $options->{verbose} >= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} >= 2 0 0 0
40 0 return { salearn => { failed => "did not find executable sa-learn", salearn_path => $salearn } };
41 }
42  
43 0 ▶ $count = $options->{fastmode} ? 1 : 5;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
44 my @passes = $options->{fastmode} ? (
45 0 ▶ { metric => "ham",
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
46 type => "ham",
47 subdir => "easy_ham_subset",
48 },
49 ) :
50 (
51 { metric => "ham",
52 type => "ham",
53 subdir => "easy_ham",
54 },
55 { metric => "ham2",
56 type => "ham",
57 subdir => "easy_ham_2",
58 },
59 { metric => "spam",
60 type => "spam",
61 subdir => "spam",
62 },
63 { metric => "spam2",
64 type => "spam",
65 subdir => "spam_2",
66 },
67 );
68  
69 # sa-learn
70 0 my %results;
71 0 for my $pass (@passes) {
72 0 my @output;
73 0 my $cmd = "$^X -T $salearn --$pass->{type} -L --no-sync '$srcdir/$pass->{subdir}' 2>&1";
74 0 ▶ print STDERR "\n# $cmd\n" if $options->{verbose} >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} >= 4 0 0 0
75 0 ▶ my $t = timeit $count, sub { @output = map { chomp; $_ } qx($cmd) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
76 0 ▶ my $maxerr = ($#output < 10) ? $#output : 10;
Branch: 1 branch
BranchTrueFalseTotal
$#output < 10 ? : 0 0 0
77 0 ▶ print STDERR join("\n# ", "", @output[0..$maxerr]) if $options->{verbose} >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} >= 4 0 0 0
78  
79 $results{salearn}{$pass->{metric}} = {
80 0 Benchmark => [@$t],
81 salearn_path => $salearn,
82 sa_version => $sa_version,
83 count => $count,
84 };
85 }
86 0 return \%results;
87 }
88  
89 1 1;
90  
91 __END__
↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/PerlCritic.pm »