blib/lib/Internals/CountObjects.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 6 / 6 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 90.1% 55 / 61 CC 8 SCAR 14.3
CC
8
Cov
94%
_dump_objects_delta
7.1
dump_objects
2.0
BEGIN
1.0
CRAP 4.2
↑ Summary CountObjects.xs »
1 package Internals::CountObjects;
2 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 $Internals::CountObjects::VERSION = '0.05';
4 }
5 # ABSTRACT: Report all allocated perl objects
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use vars qw( @ISA @EXPORT_OK %EXPORT_TAGS );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 require XSLoader;
11 1 XSLoader::load( __PACKAGE__, $Internals::CountObjects::VERSION );
12  
13 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 @ISA = 'Exporter';
15 1 @EXPORT_OK = qw(
16 objects
17 dump_objects
18 );
19 1 %EXPORT_TAGS = (
20 all => \ @EXPORT_OK,
21 );
22  
23 # Provided by CountObjects.xs
24 sub objects;
25  
26 2 ▶sub dump_objects {
Subroutine dump_objects: called CC=2 SCAR=6.9
Pod documented
27 2 local $@;
28 return
29 2 ▶ $_[0]
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 1 1 2
30 ? _dump_objects_delta( $_[0] )
31 : _dump_objects();
32 }
33  
34 1 ▶sub _dump_objects {
Subroutine _dump_objects: called CC=1 SCAR=0.0
35 1 my $objects = objects();
36 return
37 join '',
38 "Memory stats\n",
39 33 map { "=$$= $_: $objects->{$_}\n" }
40 1 sort { $objects->{$b} <=> $objects->{$a} }
41 keys %$objects;
42 }
43  
44 1 ▶sub _dump_objects_delta {
Subroutine _dump_objects_delta: called CC=7 SCAR=19.6
45 1 my $prev_objects = $_[0];
46 1 my $objects = objects();
47  
48 1 my %delta;
49 @delta{
50 1 keys( %$objects ),
51 keys( %$prev_objects ),
52 } = ();
53  
54 1 for ( keys %delta ) {
55 33 ▶ my $prev = $prev_objects->{$_} || 0;
Condition50%1/2
$prev_objects->{$_} || 0
l!l
330
MC/DC0%0/1
$prev_objects->{$_} || 0
$prev_objects->{$_}
Truth table50%1/2
A
A= $prev_objects->{$_}
Aresult
11
00
56 33 ▶ my $now = $objects ->{$_} || 0;
Condition50%1/2
$objects->{$_} || 0
l!l
330
MC/DC0%0/1
$objects->{$_} || 0
$objects->{$_}
Truth table50%1/2
A
A= $objects->{$_}
Aresult
11
00
57 33 $delta{$_} = $now - $prev;
58 }
59  
60 return
61 join '',
62 "Memory stats (delta from previous)\n",
63 map {
64 33 my $prev = $prev_objects->{$_};
65 33 ▶ my $now = $objects ->{$_} || 0;
Condition50%1/2
$objects->{$_} || 0
l!l
330
MC/DC0%0/1
$objects->{$_} || 0
$objects->{$_}
Truth table50%1/2
A
A= $objects->{$_}
Aresult
11
00
66 33 my $d = $delta{$_};
67 33 ▶ if ($d > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($d > 0) 10 23 33
68 10 $d = "+$d";
69 }
70  
71 $d
72 33 ▶ ? "=$$= $_: $now ($d)\n"
Branch: 1 branch
BranchTrueFalseTotal
$d ? : 11 22 33
73 : "=$$= $_: $now\n";
74 }
75 1 sort { $delta{$b} <=> $delta{$a} }
76 keys %delta;
77 }
78  
79 1 'Insisting on maintaining dignity at all costs is paralyzing. Mistakes are informative, and so is playing the fool'
80  
81 __END__
↑ Summary CountObjects.xs »