line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Internals::CountObjects; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
25848
|
$Internals::CountObjects::VERSION = '0.05'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Report all allocated perl objects |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
50
|
|
8
|
1
|
|
|
1
|
|
8
|
use vars qw( @ISA @EXPORT_OK %EXPORT_TAGS ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
111
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require XSLoader; |
11
|
|
|
|
|
|
|
XSLoader::load( __PACKAGE__, $Internals::CountObjects::VERSION ); |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
11
|
use Exporter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
597
|
|
14
|
|
|
|
|
|
|
@ISA = 'Exporter'; |
15
|
|
|
|
|
|
|
@EXPORT_OK = qw( |
16
|
|
|
|
|
|
|
objects |
17
|
|
|
|
|
|
|
dump_objects |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
%EXPORT_TAGS = ( |
20
|
|
|
|
|
|
|
all => \ @EXPORT_OK, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Provided by CountObjects.xs |
24
|
|
|
|
|
|
|
sub objects; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub dump_objects { |
27
|
2
|
|
|
2
|
1
|
9402
|
local $@; |
28
|
|
|
|
|
|
|
return |
29
|
2
|
100
|
|
|
|
15
|
$_[0] |
30
|
|
|
|
|
|
|
? _dump_objects_delta( $_[0] ) |
31
|
|
|
|
|
|
|
: _dump_objects(); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _dump_objects { |
35
|
1
|
|
|
1
|
|
7508
|
my $objects = objects(); |
36
|
|
|
|
|
|
|
return |
37
|
26
|
|
|
|
|
80
|
join '', |
38
|
|
|
|
|
|
|
"Memory stats\n", |
39
|
93
|
|
|
|
|
107
|
map { "=$$= $_: $objects->{$_}\n" } |
40
|
1
|
|
|
|
|
32
|
sort { $objects->{$b} <=> $objects->{$a} } |
41
|
|
|
|
|
|
|
keys %$objects; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _dump_objects_delta { |
45
|
1
|
|
|
1
|
|
4
|
my $prev_objects = $_[0]; |
46
|
1
|
|
|
|
|
7381
|
my $objects = objects(); |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
25
|
my %delta; |
49
|
|
|
|
|
|
|
@delta{ |
50
|
1
|
|
|
|
|
31
|
keys( %$objects ), |
51
|
|
|
|
|
|
|
keys( %$prev_objects ), |
52
|
|
|
|
|
|
|
} = (); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
11
|
for ( keys %delta ) { |
55
|
26
|
|
50
|
|
|
64
|
my $prev = $prev_objects->{$_} || 0; |
56
|
26
|
|
50
|
|
|
50
|
my $now = $objects ->{$_} || 0; |
57
|
26
|
|
|
|
|
51
|
$delta{$_} = $now - $prev; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
return |
61
|
26
|
|
|
|
|
41
|
join '', |
62
|
|
|
|
|
|
|
"Memory stats (delta from previous)\n", |
63
|
|
|
|
|
|
|
map { |
64
|
79
|
|
|
|
|
122
|
my $prev = $prev_objects->{$_}; |
65
|
26
|
|
50
|
|
|
64
|
my $now = $objects ->{$_} || 0; |
66
|
26
|
|
|
|
|
32
|
my $d = $delta{$_}; |
67
|
26
|
100
|
|
|
|
56
|
if ($d > 0) { |
68
|
10
|
|
|
|
|
20
|
$d = "+$d"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
$d |
72
|
26
|
100
|
|
|
|
127
|
? "=$$= $_: $now ($d)\n" |
73
|
|
|
|
|
|
|
: "=$$= $_: $now\n"; |
74
|
|
|
|
|
|
|
} |
75
|
1
|
|
|
|
|
13
|
sort { $delta{$b} <=> $delta{$a} } |
76
|
|
|
|
|
|
|
keys %delta; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
'Insisting on maintaining dignity at all costs is paralyzing. Mistakes are informative, and so is playing the fool' |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |