Run3/ProfPP.pm

filter: Statementstmt 100% 43 / 43 Branchbran 50.0% 4 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 83.7% 62 / 74 CC 7 SCAR 7.2
CC
7
Cov
86%
handle_run_exit
3.1
handle_app_exit
3.1
_r
2.0
CRAP 2.0
« Run3/ProfReporter.pm ↑ Summary Run3/ProfArrayBuffer.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package IPC::Run3::ProfPP;
4  
5 1 our $VERSION = 0.049;
6  
7 =head1 NAME
8  
9 IPC::Run3::ProfPP - Generate reports from IPC::Run3 profiling data
10  
11 =head1 SYNOPSIS
12  
13 =head1 DESCRIPTION
14  
15 Used by IPC::Run3 and/or run3profpp to print out profiling reports for
16 human readers. Use other classes for extracting data in other ways.
17  
18 The output methods are plain text, override these (see the source for
19 now) to provide other formats.
20  
21 This class generates reports on each run3_exit() and app_exit() call.
22  
23 =cut
24  
25 1 require IPC::Run3::ProfReporter;
26 1 our @ISA = qw( IPC::Run3::ProfReporter );
27  
28 1 ▶use POSIX qw( floor );
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 =head1 METHODS
31  
32 =head2 C<< IPC::Run3::ProfPP->new() >>
33  
34 Returns a new profile reporting object.
35  
36 =cut
37  
38 11 ▶sub _emit { shift; warn @_ }
Subroutine _emit: called CC=1 SCAR=0.0
39  
40 8 ▶sub _t {
Subroutine _t: called CC=1 SCAR=0.0
41 8 sprintf "%10.6f secs", @_;
42 }
43  
44 3 ▶sub _r {
Subroutine _r: called CC=2 SCAR=7.1
45 3 my ( $num, $denom ) = @_;
46 3 ▶ return () unless $denom;
Branch: 1 branch
BranchTrueFalseTotal
unless $denom 0 3 3
47 3 sprintf "%10.6f", $num / $denom;
48 }
49  
50 5 ▶sub _pct {
Subroutine _pct: called CC=2 SCAR=7.1
51 5 my ( $num, $denom ) = @_;
52 5 ▶ return () unless $denom;
Branch: 1 branch
BranchTrueFalseTotal
unless $denom 0 5 5
53 5 sprintf " (%3d%%)", floor( 100 * $num / $denom + 0.5 );
54 }
55  
56 =head2 C<< $profpp->handle_app_call() >>
57  
58 =cut
59  
60 1 ▶sub handle_app_call {
Subroutine handle_app_call: called CC=1 SCAR=0.0
Pod documented
61 1 my $self = shift;
62 $self->_emit("IPC::Run3 parent: ",
63 1 join( " ", @{$self->get_app_cmd} ),
64 "\n",
65 );
66  
67 1 $self->{NeedNL} = 1;
68 }
69  
70 =head2 C<< $profpp->handle_app_exit() >>
71  
72 =cut
73  
74 1 ▶sub handle_app_exit {
Subroutine handle_app_exit: called CC=3 SCAR=11.2
Pod documented
75 1 my $self = shift;
76  
77 1 ▶ $self->_emit("\n") if $self->{NeedNL} && $self->{NeedNL} != 1;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"NeedNL"} and $self->{"NeedNL"} != 1 1 0 1
Condition33%1/3
$self->{"NeedNL"} and $self->{"NeedNL"} != 1
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"NeedNL"} and $self->{"NeedNL"} != 1
$self->{"NeedNL"} $self->{"NeedNL"} != 1
Truth table33%1/3
A and B
A= $self->{"NeedNL"}B= $self->{"NeedNL"} != 1
ABresult
0X0
100
111
78  
79 1 $self->_emit( "IPC::Run3 total elapsed: ",
80 _t( $self->get_app_cumulative_time ),
81 "\n");
82 1 $self->_emit( "IPC::Run3 calls to run3(): ",
83 sprintf( "%10d", $self->get_run_count ),
84 "\n");
85 1 $self->_emit( "IPC::Run3 total spent in run3(): ",
86 _t( $self->get_run_cumulative_time ),
87 _pct( $self->get_run_cumulative_time, $self->get_app_cumulative_time ),
88 ", ",
89 _r( $self->get_run_cumulative_time, $self->get_run_count ),
90 " per call",
91 "\n");
92 1 my $exclusive =
93 $self->get_app_cumulative_time - $self->get_run_cumulative_time;
94 1 $self->_emit( "IPC::Run3 total spent not in run3(): ",
95 _t( $exclusive ),
96 _pct( $exclusive, $self->get_app_cumulative_time ),
97 "\n");
98 1 $self->_emit( "IPC::Run3 total spent in children: ",
99 _t( $self->get_sys_cumulative_time ),
100 _pct( $self->get_sys_cumulative_time, $self->get_app_cumulative_time ),
101 ", ",
102 _r( $self->get_sys_cumulative_time, $self->get_run_count ),
103 " per call",
104 "\n");
105 1 my $overhead =
106 $self->get_run_cumulative_time - $self->get_sys_cumulative_time;
107 1 $self->_emit( "IPC::Run3 total overhead: ",
108 _t( $overhead ),
109 _pct(
110 $overhead,
111 $self->get_sys_cumulative_time
112 ),
113 ", ",
114 _r( $overhead, $self->get_run_count ),
115 " per call",
116 "\n");
117 }
118  
119 =head2 C<< $profpp->handle_run_exit() >>
120  
121 =cut
122  
123 1 ▶sub handle_run_exit {
Subroutine handle_run_exit: called CC=3 SCAR=11.4
Pod documented
124 1 my $self = shift;
125 1 my $overhead = $self->get_run_time - $self->get_sys_time;
126  
127 1 ▶ $self->_emit("\n") if $self->{NeedNL} && $self->{NeedNL} != 2;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"NeedNL"} and $self->{"NeedNL"} != 2 1 0 1
Condition33%1/3
$self->{"NeedNL"} and $self->{"NeedNL"} != 2
!ll&&!rl&&r
001
MC/DC0%0/2
$self->{"NeedNL"} and $self->{"NeedNL"} != 2
$self->{"NeedNL"} $self->{"NeedNL"} != 2
Truth table33%1/3
A and B
A= $self->{"NeedNL"}B= $self->{"NeedNL"} != 2
ABresult
0X0
100
111
128 1 $self->{NeedNL} = 3;
129  
130 $self->_emit( "IPC::Run3 child: ",
131 1 join( " ", @{$self->get_run_cmd} ),
132 "\n");
133 1 $self->_emit( "IPC::Run3 run3() : ", _t( $self->get_run_time ), "\n",
134 "IPC::Run3 child : ", _t( $self->get_sys_time ), "\n",
135 "IPC::Run3 overhead: ", _t( $overhead ),
136 _pct( $overhead, $self->get_sys_time ),
137 "\n");
138 }
139  
140 =head1 LIMITATIONS
141  
142 =head1 COPYRIGHT
143  
144 Copyright 2003, R. Barrie Slaymaker, Jr., All Rights Reserved
145  
146 =head1 LICENSE
147  
148 You may use this module under the terms of the BSD, Artistic, or GPL licenses,
149 any version.
150  
151 =head1 AUTHOR
152  
153 Barrie Slaymaker E<lt>barries@slaysys.comE<gt>
154  
155 =cut
156  
157 1 1;
« Run3/ProfReporter.pm ↑ Summary Run3/ProfArrayBuffer.pm »