| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
$salearn and -x $salearn
MC/DC0%0/2
$salearn and -x $salearn
$salearn
-x $salearn
Truth table0%0/3
A and B
A= $salearnB= -x $salearn
| |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | print STDERR "# did not find executable $salearn\n" if $options->{verbose} >= 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 44 | my @passes = $options->{fastmode} ? ( | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | { metric => "ham", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | print STDERR join("\n# ", "", @output[0..$maxerr]) if $options->{verbose} >= 4; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||