| 1 | package Linux::Smaps::Tiny::PP; | ||||||||||||
| 2 | 3 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 3 | $Linux::Smaps::Tiny::PP::AUTHORITY = 'cpan:AVAR'; | |||||||||||
| 4 | } | ||||||||||||
| 5 | { | ||||||||||||
| 6 | 3 | $Linux::Smaps::Tiny::PP::VERSION = '0.10'; | |||||||||||
| 7 | } | ||||||||||||
| 8 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 3 | ▶ | use warnings FATAL => "all"; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 3 | ▶ | sub __get_smaps_summary { | ||||||||||
|
Subroutine
__get_smaps_summary: called CC=6 SCAR=17.9
| |||||||||||||
| 12 | 3 | ▶ | my $proc_id= shift || "self"; | ||||||||||
|
Condition100%2/2
shift() || 'self'
MC/DC100%1/1
shift() || 'self'
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 13 | 3 | my $smaps_file= "/proc/$proc_id/smaps"; | |||||||||||
| 14 | open my $fh, "<", $smaps_file | ||||||||||||
| 15 | 3 | ▶ | or do { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 16 | 1 | my $errnum= 0+$!; # numify | |||||||||||
| 17 | 1 | my $errmsg= "$!"; # stringify | |||||||||||
| 18 | 1 | my $msg= "In get_smaps_summary, failed to read '$smaps_file': [$errnum] $errmsg"; | |||||||||||
| 19 | |||||||||||||
| 20 | 1 | die $msg; | |||||||||||
| 21 | }; | ||||||||||||
| 22 | 2 | my %sum; | |||||||||||
| 23 | 2 | ▶ | while (<$fh>) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | 6150 | ▶ | next unless substr($_,-3) eq "kB\n"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 25 | 5412 | my ($field, $value)= split /:/,$_; | |||||||||||
| 26 | 3 | ▶ | no warnings 'numeric'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 27 | 5412 | ▶ | $sum{$field}+=$value if $value; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 28 | } | ||||||||||||
| 29 | 2 | close $fh; | |||||||||||
| 30 | 2 | return \%sum; | |||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | 3 | 1; | |||||||||||