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