blib/lib/Memory/Process.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 5 / 5 totaltotal 100% 60 / 60 CC 5 SCAR 7.3
CC
5
Cov
100%
report
4.0
record
2.0
BEGIN
1.0
CRAP 2.1
↑ Summary
1 package Memory::Process;
2  
3 8 ▶use base qw(Memory::Usage);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 8 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # Constants.
10 8 Readonly::Scalar our $EMPTY_STR => q{};
11  
12 8 our $VERSION = 0.06;
13  
14 # Record.
15 7 ▶sub record {
Subroutine record: called CC=2 SCAR=6.9
Pod documented
16 7 my ($self, $message, $pid) = @_;
17 7 ▶ if (! defined $message) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $message) 2 5 7
18 2 $message = $EMPTY_STR;
19 }
20 7 return $self->SUPER::record($message, $pid);
21 }
22  
23 # Print report to STDERR.
24 2 ▶sub dump {
Subroutine dump: called CC=1 SCAR=0.0
Pod documented
25 2 my $self = shift;
26 2 return print STDERR scalar $self->report;
27 }
28  
29 # Get report.
30 4 ▶sub report {
Subroutine report: called CC=4 SCAR=13.9
Pod documented
31 4 my $self = shift;
32 4 my $report = $self->SUPER::report;
33 4 my @report_full = split m/\n/ms, $report;
34 4 my @report = ();
35 4 ▶ if (@report_full > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@report_full > 2) 1 3 4
36 1 @report = ($report_full[0], $report_full[-2], $report_full[-1]);
37 };
38 4 my $report_scalar = (join "\n", @report);
39 4 ▶ if ($report_scalar ne $EMPTY_STR) {
Branch: 1 branch
BranchTrueFalseTotal
if ($report_scalar ne $Memory::Process::EMPTY_STR) 1 3 4
40 1 $report_scalar .= "\n";
41 }
42 4 ▶ return wantarray ? @report : $report_scalar;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 3 4
43 }
44  
45 # Reset records.
46 1 ▶sub reset {
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
47 1 my $self = shift;
48 1 @{$self} = ();
49 1 return;
50 }
51  
52 # Get state.
53 2 ▶sub state {
Subroutine state: called CC=1 SCAR=0.0
Pod documented
54 2 my $self = shift;
55 2 return [@{$self}];
56 }
57  
58 8 1;
59  
60 __END__
↑ Summary