1 package IPC::Run3::ProfPP;
7 IPC::Run3::ProfPP - Generate reports from IPC::Run3 profiling data
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.
16 The output methods are plain text, override these (see the source for
17 now) to provide other formats.
19 This class generates reports on each run3_exit() and app_exit() call.
23 require IPC::Run3::ProfReporter;
24 @ISA = qw( IPC::Run3::ProfReporter );
27 use POSIX qw( floor );
31 =head2 C<< IPC::Run3::ProfPP->new() >>
33 Returns a new profile reporting object.
37 sub _emit { shift; warn @_ }
40 sprintf "%10.6f secs", @_;
44 my ( $num, $denom ) = @_;
45 return () unless $denom;
46 sprintf "%10.6f", $num / $denom;
50 my ( $num, $denom ) = @_;
51 return () unless $denom;
52 sprintf " (%3d%%)", floor( 100 * $num / $denom + 0.5 );
55 =head2 C<< $profpp->handle_app_call() >>
61 $self->_emit("IPC::Run3 parent: ",
62 join( " ", @{$self->get_app_cmd} ),
69 =head2 C<< $profpp->handle_app_exit() >>
76 $self->_emit("\n") if $self->{NeedNL} && $self->{NeedNL} != 1;
78 $self->_emit( "IPC::Run3 total elapsed: ",
79 _t( $self->get_app_cumulative_time ),
81 $self->_emit( "IPC::Run3 calls to run3(): ",
82 sprintf( "%10d", $self->get_run_count ),
84 $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 ),
88 _r( $self->get_run_cumulative_time, $self->get_run_count ),
92 $self->get_app_cumulative_time - $self->get_run_cumulative_time;
93 $self->_emit( "IPC::Run3 total spent not in run3(): ",
95 _pct( $exclusive, $self->get_app_cumulative_time ),
97 $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 ),
101 _r( $self->get_sys_cumulative_time, $self->get_run_count ),
105 $self->get_run_cumulative_time - $self->get_sys_cumulative_time;
106 $self->_emit( "IPC::Run3 total overhead: ",
110 $self->get_sys_cumulative_time
113 _r( $overhead, $self->get_run_count ),
118 =head2 C<< $profpp->handle_run_exit() >>
122 sub handle_run_exit {
124 my $overhead = $self->get_run_time - $self->get_sys_time;
126 $self->_emit("\n") if $self->{NeedNL} && $self->{NeedNL} != 2;
129 $self->_emit( "IPC::Run3 child: ",
130 join( " ", @{$self->get_run_cmd} ),
132 $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 ),
143 Copyright 2003, R. Barrie Slaymaker, Jr., All Rights Reserved
147 You may use this module under the terms of the BSD, Artistic, or GPL licenses,
152 Barrie Slaymaker E<lt>barries@slaysys.comE<gt>