PerlBench/Stats.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 4 / 4 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 91.8% 34 / 37 CC 5 SCAR 13.5
CC
5
Cov
97%
calc_stats
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.9
« benchlib.pl ↑ Summary
1 package PerlBench::Stats;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 our @EXPORT_OK = qw(calc_stats);
7  
8 6 ▶sub calc_stats {
Subroutine calc_stats: called CC=5 SCAR=16.1
Pod undocumented
9 6 my($samples, $hash) = @_;
10 6 ▶ $hash ||= {};
Condition50%1/2
$hash ||= {}
l!l
06
MC/DC0%0/1
$hash ||= {}
$hash
Truth table50%1/2
A
A= $hash
Aresult
11
00
11 6 my @t = sort {$a <=> $b} @$samples;
12 6 my $n = @t;
13 6 ▶ return undef unless $n;
Branch: 1 branch
BranchTrueFalseTotal
unless $n 1 5 6
14  
15 5 my $sum = 0;
16 5 my $sum2 = 0;
17 5 for (@t) {
18 12 $sum += $_;
19 12 $sum2 += $_ * $_;
20 }
21  
22 5 $hash->{avg} = $sum / $n;
23 5 $hash->{stddev} = sqrt(($sum2 - ($sum * $sum)/$n) / $n);
24  
25 5 $hash->{min} = $t[0];
26 5 ▶ $hash->{med} = ($n % 2) ? $t[$n/2] : (($t[$n/2-1] + $t[$n/2])/2);
Branch: 1 branch
BranchTrueFalseTotal
$n % 2 ? : 2 3 5
27 5 $hash->{max} = $t[-1];
28 5 $hash->{n} = $n;
29  
30 5 return $hash;
31 }
32  
33 2 1;
« benchlib.pl ↑ Summary