line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Memory::Process; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Pragmas. |
4
|
8
|
|
|
8
|
|
33647
|
use base qw(Memory::Usage); |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
6185
|
|
5
|
8
|
|
|
8
|
|
5326
|
use strict; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
154
|
|
6
|
8
|
|
|
8
|
|
42
|
use warnings; |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
184
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Modules. |
9
|
8
|
|
|
8
|
|
6604
|
use Readonly; |
|
8
|
|
|
|
|
25147
|
|
|
8
|
|
|
|
|
2828
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Constants. |
12
|
|
|
|
|
|
|
Readonly::Scalar our $EMPTY_STR => q{}; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Version. |
15
|
|
|
|
|
|
|
our $VERSION = 0.04; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Record. |
18
|
|
|
|
|
|
|
sub record { |
19
|
7
|
|
|
7
|
1
|
1003324
|
my ($self, $message, $pid) = @_; |
20
|
7
|
100
|
|
|
|
33
|
if (! defined $message) { |
21
|
2
|
|
|
|
|
6
|
$message = $EMPTY_STR; |
22
|
|
|
|
|
|
|
} |
23
|
7
|
|
|
|
|
53
|
return $self->SUPER::record($message, $pid); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Print report to STDERR. |
27
|
|
|
|
|
|
|
sub dump { |
28
|
2
|
|
|
2
|
1
|
3326
|
my $self = shift; |
29
|
2
|
|
|
|
|
12
|
return print STDERR scalar $self->report; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Get report. |
33
|
|
|
|
|
|
|
sub report { |
34
|
4
|
|
|
4
|
1
|
850
|
my $self = shift; |
35
|
4
|
|
|
|
|
31
|
my $report = $self->SUPER::report; |
36
|
4
|
|
|
|
|
183
|
my @report_full = split m/\n/ms, $report; |
37
|
4
|
|
|
|
|
12
|
my @report = (); |
38
|
4
|
100
|
|
|
|
17
|
if (@report_full > 2) { |
39
|
1
|
|
|
|
|
8
|
@report = ($report_full[0], $report_full[-2], $report_full[-1]); |
40
|
|
|
|
|
|
|
}; |
41
|
4
|
|
|
|
|
15
|
my $report_scalar = (join "\n", @report); |
42
|
4
|
100
|
|
|
|
16
|
if ($report_scalar ne $EMPTY_STR) { |
43
|
1
|
|
|
|
|
6
|
$report_scalar .= "\n"; |
44
|
|
|
|
|
|
|
} |
45
|
4
|
100
|
|
|
|
125
|
return wantarray ? @report : $report_scalar; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Reset records. |
49
|
|
|
|
|
|
|
sub reset { |
50
|
1
|
|
|
1
|
1
|
944
|
my $self = shift; |
51
|
1
|
|
|
|
|
2
|
@{$self} = (); |
|
1
|
|
|
|
|
3
|
|
52
|
1
|
|
|
|
|
3
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Get state. |
56
|
|
|
|
|
|
|
sub state { |
57
|
2
|
|
|
2
|
1
|
137
|
my $self = shift; |
58
|
2
|
|
|
|
|
3
|
return [@{$self}]; |
|
2
|
|
|
|
|
10
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |