PerlStone2015.pm

filter: Statementstmt 37.3% 25 / 67 Branchbran 4.5% 1 / 22 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 63.6% 7 / 11 Podpod 100% 2 / 2 totaltotal 32.4% 35 / 108 CC 14 SCAR 39.7
CC
14
Cov
28%
perlstone
107.3
_find_sub_results
20.0
main
2.0
CRAP 53.0
↑ Summary PerlStone2015/dpath.pm »
1 # -*- mode: cperl -*-
2 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 package Benchmark::Perl::Formance::Plugin::PerlStone2015;
7 # git description: v0.001-3-g97bd876
8  
9 1 our $AUTHORITY = 'cpan:SCHWIGON';
10 # ABSTRACT: Benchmark::Perl::Formance plugin covering a representative set of sub benchmarks
11 1 $Benchmark::Perl::Formance::Plugin::PerlStone2015::VERSION = '0.002';
12 1 ▶use Data::DPath 'dpath', 'dpathi';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 our @default_subtests = qw( binarytrees
16 fasta
17 regex
18  
19 regexdna
20 nbody
21 revcomp
22 spectralnorm
23 fib
24  
25 01overview
26 02bits
27 03operator
28 04control
29 05regex
30 06subroutines
31 07lists
32 08capture
33 09data
34 10packages
35 11modules
36 12objects
37 13overloading
38 14tie
39 15unicode
40 16ioipc
41 17concurrency
42 18compiling
43 19commandline
44 );
45  
46 # Benchmarks using 'threads' can have an impact to programs running
47 # after them, so push them to the end of the list to avoid confusion
48 # as long as possible.
49 1 ▶if ($Config{usethreads}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Benchmark::Perl::Formance::Plugin::PerlStone2015::Config{"usethreads"}) 0 1 1
50 0 push @default_subtests, (qw(fannkuch
51 mandelbrot
52 ));
53 }
54  
55 sub perlstone
56 0 ▶{
Subroutine perlstone: not called CC=11 SCAR=46.8
Pod documented
57 0 my ($options) = @_;
58  
59 1 ▶ no strict "refs"; ## no critic
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 0 my %results = ();
62 0 my $verbose = $options->{verbose};
63 0 my $subtests = $options->{subtests};
64 0 ▶ my @subtests = scalar(@{$subtests||[]}) ? @{$subtests||[]} : @default_subtests;
Branch: 1 branch
BranchTrueFalseTotal
scalar @{$subtests or [];} ? : 0 0 0
Condition0%0/4
$subtests || []
l!l
00
$subtests || []
l!l
00
MC/DC0%0/1
$subtests || []
$subtests
MC/DC0%0/1
$subtests || []
$subtests
Truth table0%0/2
A
A= $subtests
Aresult
11
00
Truth table0%0/2
A
A= $subtests
Aresult
11
00
65  
66 0 for my $subtest (@subtests)
67 {
68 0 ▶ print STDERR "# - $subtest...\n" if $options->{verbose} > 2;
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} > 2 0 0 0
69 0 eval "use ".__PACKAGE__."::$subtest"; ## no critic
70 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 0 0
71 0 ▶ print STDERR "# Skip PerlStone plugin '$subtest'" if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 0 0
72 0 ▶ print STDERR ":$@" if $verbose >= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose >= 2 0 0 0
73 0 ▶ print STDERR "\n" if $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if $verbose 0 0 0
74 }
75 else {
76 0 eval {
77 0 my $main = __PACKAGE__."::$subtest"."::main";
78 0 $results{$subtest} = $main->($options);
79 };
80 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
81 0 $results{$subtest} = { failed => $@ };
82 }
83 }
84 }
85 0 return \%results;
86 }
87  
88 sub _find_sub_results
89 0 ▶{
Subroutine _find_sub_results: not called CC=4 SCAR=30.0
90 0 my ($RESULTS) = @_;
91  
92 0 my %sub_results = ();
93  
94 0 my $benchmarks = dpathi($RESULTS)->isearch("//Benchmark");
95 0 ▶ while ($benchmarks->isnt_exhausted) {
Branch: 1 branch
BranchTrueFalseTotal
if ($benchmarks->isnt_exhausted) 0 0 0
96 0 my @keys;
97 0 my $benchmark = $benchmarks->value;
98 0 my $ancestors = $benchmark->isearch ("/::ancestor");
99  
100 0 ▶ while ($ancestors->isnt_exhausted) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ancestors->isnt_exhausted) 0 0 0
101 0 my $key = $ancestors->value->first_point->{attrs}{key};
102 0 ▶ push @keys, $key if defined $key;
Branch: 1 branch
BranchTrueFalseTotal
if defined $key 0 0 0
103 }
104 0 $sub_results{join(".", reverse @keys)} = ${$benchmark->first_point->{ref}}->{Benchmark}[0];
105 }
106 0 return \%sub_results;
107 }
108  
109 sub _aggregations
110 0 ▶{
Subroutine _aggregations: not called CC=1 SCAR=1.7
111 0 my ($results, $options) = @_;
112  
113 0 my $sub_results = _find_sub_results($results);
114 1 ▶ use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
115 #print STDERR "sub_results = ".Dumper($sub_results);
116  
117 0 my $basemean = 1; # calculate this from normalized sub_results
118 return {
119 #basemean => { Benchmark => [ $basemean ] },
120 0 subresults => $sub_results,
121 };
122 }
123  
124 sub main
125 0 ▶{
Subroutine main: not called CC=1 SCAR=6.9
Pod documented
126 0 my ($options) = @_;
127  
128 0 my $results = perlstone($options);
129  
130 0 $results->{perlstone} = _aggregations($results, $options);
131 0 return $results;
132 }
133  
134 1 1; # End of Benchmark::Perl::Formance::Plugin::PerlStone2015
135  
136 __END__
↑ Summary PerlStone2015/dpath.pm »