Test/Evo/Benchmark.pm

filter: Statementstmt 56.6% 17 / 30 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 51.1% 22 / 43 SCAR 21.6
CC
5
Cov
47%
faster_ok
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 8.7
« Evo.pm ↑ Summary Evo/Attr.pm »
1 package Test::Evo::Benchmark;
2 5 ▶use Evo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use Benchmark 'timeit';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 5 our @EXPORT = qw(faster_ok);
10  
11 sub faster_ok {
12 0 ▶ my %args = @_;
Subroutine faster_ok: not called CC=5 SCAR=34.0
Pod undocumented
13  
14 0 ▶ $args{$_} or croak "define $_ option" for qw(iters fn expect);
Branch: 1 branch
BranchTrueFalseTotal
$args{$_} or croak("define $_ option") 0 0 0
15 0 my ($iters, $fn, $expect, $diag) = @args{qw(iters fn expect diag)};
16  
17  
18 0 my $t = timeit($iters, $fn);
19 0 local $Test::Builder::Level = $Test::Builder::Level + 1;
20  
21 0 ▶ if ($t->cpu_a) {
Branch: 1 branch
BranchTrueFalseTotal
if ($t->cpu_a) { } 0 0 0
22 0 my $perf = $iters / $t->cpu_a;
23 0 ▶ do { diag timestr $t; diag $perf } if $diag;
Branch: 1 branch
BranchTrueFalseTotal
if ($diag) 0 0 0
24 0 ok $perf > $expect, "$perf > $expect";
25 }
26 else {
27 0 fail "too few itreations $iters";
28 }
29  
30 0 $t;
31 }
32  
33 5 1;
34  
35 __END__
« Evo.pm ↑ Summary Evo/Attr.pm »