blib/lib/Plack/Middleware/MemoryUsage.pm

filter: Statementstmt 76.3% 29 / 38 Branchbran 50.0% 2 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 88.8% 8 / 9 Podpod 50.0% 1 / 2 totaltotal 71.4% 40 / 56 CC 6 SCAR 13.3
CC
6
Cov
70%
call
8.7
__ANON__
6.0
memory_usage
3.0
CRAP 3.8
↑ Summary
1 package Plack::Middleware::MemoryUsage;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use parent qw( Plack::Middleware );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Plack::Util::Accessor qw( callback packages);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 our $VERSION = '0.03';
10  
11 4 ▶use B::Size2::Terse;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Devel::Symdump;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶sub call {
Subroutine call: called CC=3 SCAR=21.6
Pod documented
15 2 my($self, $env) = @_;
16  
17 2 my $before = $self->memory_usage();
18 0 my $res = $self->app->($env);
19 0 my $after = $self->memory_usage();
20 0 my $diff = {};
21  
22 0 for my $pkg (keys %$after) {
23 0 ▶ $diff->{$pkg} = $after->{$pkg} - ($before->{$pkg} || 0);
Condition0%0/2
$before->{$pkg} || 0
l!l
00
MC/DC0%0/1
$before->{$pkg} || 0
$before->{$pkg}
Truth table0%0/2
A
A= $before->{$pkg}
Aresult
11
00
24 }
25  
26 0 ▶ $self->response_cb($res, sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
27 0 my $res = shift;
28 0 ▶ $self->callback->( $env, $res, $before, $after, $diff )
Branch: 1 branch
BranchTrueFalseTotal
if $self->callback 0 0 0
29 if $self->callback;
30 0 });
31 }
32  
33 2 ▶sub memory_usage {
Subroutine memory_usage: called CC=3 SCAR=11.0
Pod undocumented
34 2 my $self = shift;
35 2 ▶ my @packages = $self->packages ? @{$self->packages} : Devel::Symdump->rnew("main")->packages;
Branch: 1 branch
BranchTrueFalseTotal
$self->packages ? : 1 1 2
36 2 my $size;
37  
38 2 for my $package ("main", @packages) {
39 4 my($subs, $opcount, $opsize) = B::Size2::Terse::package_size($package);
40 2 $size->{$package} = $opsize;
41 }
42 0 return $size;
43 }
44  
45 4 1;
46  
47 __END__
↑ Summary