blib/lib/Devel/StatProfiler.pm

filter: Statementstmt 53.0% 43 / 81 Branchbran 37.1% 23 / 62 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 68.7% 11 / 16 Podpod 0.0% 0 / 6 totaltotal 45.8% 77 / 168 CC 35 SCAR 39.3
CC
35
Cov
46%
import
82.8
import
82.8
write_inc_path
6.0
CRAP 50.9
« blib/lib/Devel/StatProfiler/Report.pm ↑ Summary blib/lib/Devel/StatProfiler/Aggregate.pm »
1 package Devel::StatProfiler;
2 # ABSTRACT: low-overhead sampling code profiler
3  
4 56 ▶use 5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 56 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 56 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 56 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 56 our $VERSION = '0.57'; # VERSION
11  
12 56 XSLoader::load(__PACKAGE__);
13  
14 56 my %args = (
15 -interval => 1,
16 -file => 1,
17 -template => 1,
18 -nostart => 0,
19 -depth => 1,
20 -source => 1,
21 -maxsize => 1,
22 -metadata => 1,
23 );
24  
25 56 my %source_args = (
26 none => 0,
27 traced_evals => 1,
28 all_evals => 2,
29 all_evals_always => 3,
30 );
31  
32 0 ▶sub _croak {
Subroutine _croak: not called CC=1 SCAR=6.9
33 0 ▶ require Carp;
Subroutine _croak: not called CC=1 SCAR=6.9
34 0 goto &Carp::croak;
35 }
36  
37 48 ▶sub import {
Subroutine import: called CC=16 SCAR=44.2
38 0 ▶ my ($package, @args) = @_;
Subroutine import: not called CC=16 SCAR=44.2
39 0 my @exporter;
40  
41 0 ▶ while (my $arg = shift @args) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $arg = shift @args) 115 48 163
if (my $arg = shift @args) 0 0 0
42 0 my $value;
43  
44 0 ▶ if ($arg !~ /^-/) {
Branch: 6 branches
BranchTrueFalseTotal
if (not $arg =~ /^-/u) { } 0 115 115
elsif (not exists $args{$arg}) { } 0 115 115
elsif ($args{$arg}) { } 111 4 115
if (not $arg =~ /^-/u) { } 0 0 0
elsif (not exists $args{$arg}) { } 0 0 0
elsif ($args{$arg}) { } 0 0 0
45 0 push @exporter, $arg;
46 0 next;
47 } elsif (!exists $args{$arg}) {
48 0 _croak("Invalid option '$arg'");
49 } elsif ($args{$arg}) {
50 0 ▶ _croak("Option '$arg' requires a value") unless @args;
Branch: 2 branches
BranchTrueFalseTotal
unless @args 0 111 111
unless @args 0 0 0
51 0 $value = shift @args;
52 }
53  
54 0 ▶ if ($arg eq '-interval') {
Branch: 16 branches
BranchTrueFalseTotal
if ($arg eq '-interval') { } 46 69 115
elsif ($arg eq '-file') { } 24 45 69
elsif ($arg eq '-template') { } 23 22 45
elsif ($arg eq '-nostart') { } 4 18 22
elsif ($arg eq '-depth') { } 0 18 18
elsif ($arg eq '-maxsize') { } 2 16 18
elsif ($arg eq '-metadata') { } 0 16 16
elsif ($arg eq '-source') { } 16 0 16
if ($arg eq '-interval') { } 0 0 0
elsif ($arg eq '-file') { } 0 0 0
elsif ($arg eq '-template') { } 0 0 0
elsif ($arg eq '-nostart') { } 0 0 0
elsif ($arg eq '-depth') { } 0 0 0
elsif ($arg eq '-maxsize') { } 0 0 0
elsif ($arg eq '-metadata') { } 0 0 0
elsif ($arg eq '-source') { } 0 0 0
55 0 set_sampling_interval($value);
56 } elsif ($arg eq '-file') {
57 0 set_output_file($value, 0);
58 } elsif ($arg eq '-template') {
59 0 set_output_file($value, 1);
60 } elsif ($arg eq '-nostart') {
61 0 set_enabled(0);
62 } elsif ($arg eq '-depth') {
63 0 set_stack_collection_depth($value);
64 } elsif ($arg eq '-maxsize') {
65 0 set_max_output_file_size($value);
66 } elsif ($arg eq '-metadata') {
67 0 set_global_metadata($value);
68 } elsif ($arg eq '-source') {
69 0 ▶ _croak("Invalid value for -source option") unless exists $source_args{$value};
Branch: 2 branches
BranchTrueFalseTotal
unless exists $source_args{$value} 0 16 16
unless exists $source_args{$value} 0 0 0
70 0 set_save_source($source_args{$value});
71 }
72 }
73  
74 0 ▶ if (@exporter) {
Branch: 2 branches
BranchTrueFalseTotal
if (@exporter) 0 48 48
if (@exporter) 0 0 0
75 0 require Exporter;
76 0 Exporter::export_to_level(__PACKAGE__, $package, @exporter);
77 }
78  
79 0 _install();
80 }
81  
82 461 ▶sub _set_profiler_state {
Subroutine _set_profiler_state: called CC=1 SCAR=1.2
83 0 ▶ srand $_[0]; # the srand is replaced with runloop.cpp:set_profiler_state
Subroutine _set_profiler_state: not called CC=1 SCAR=1.2
84 }
85  
86 211 ▶sub disable_profile { _set_profiler_state(0) }
Subroutine disable_profile: called CC=1 SCAR=0.0
Pod undocumented
87 212 ▶sub enable_profile { _set_profiler_state(1) }
Subroutine enable_profile: called CC=1 SCAR=0.0
Pod undocumented
88 38 ▶sub stop_profile { _set_profiler_state(2) }
Subroutine stop_profile: called CC=1 SCAR=0.0
Pod undocumented
89  
90 1 ▶sub save_source {
Subroutine save_source: called CC=2 SCAR=7.1
Pod undocumented
91 1 my ($value) = @_;
92 1 ▶ _croak("Invalid value for save_source option") unless exists $source_args{$value};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $source_args{$value} 0 1 1
93 1 set_save_source($source_args{$value});
94 }
95  
96 2 ▶sub guarded_section {
Subroutine guarded_section: called CC=1 SCAR=0.0
Pod undocumented
97 2 my ($section_name) = @_;
98 2 require Devel::StatProfiler::SectionGuard;
99 2 return Devel::StatProfiler::SectionGuard->new(section_name => $section_name);
100 }
101  
102 0 ▶sub write_inc_path {
Subroutine write_inc_path: not called CC=2 SCAR=17.9
Pod undocumented
103 0 ▶ my ($at_inc) = $_[0] // \@INC;
Condition0%0/2
$_[0] // \@INC
l!l
00
MC/DC0%0/1
$_[0] // \@INC
$_[0]
Truth table0%0/2
A
A= $_[0]
Aresult
11
00
104  
105 0 write_custom_metadata("\x00at_inc", join "\x00", @$at_inc);
106 }
107  
108 56 1;
109  
110 __END__
« blib/lib/Devel/StatProfiler/Report.pm ↑ Summary blib/lib/Devel/StatProfiler/Aggregate.pm »