our
$VERSION
= 0.049;
our
@ISA
=
qw( IPC::Run3::ProfReporter )
;
sub
_emit {
shift
;
warn
@_
}
sub
_t {
sprintf
"%10.6f secs"
,
@_
;
}
sub
_r {
my
(
$num
,
$denom
) =
@_
;
return
()
unless
$denom
;
sprintf
"%10.6f"
,
$num
/
$denom
;
}
sub
_pct {
my
(
$num
,
$denom
) =
@_
;
return
()
unless
$denom
;
sprintf
" (%3d%%)"
, floor( 100 *
$num
/
$denom
+ 0.5 );
}
sub
handle_app_call {
my
$self
=
shift
;
$self
->_emit(
"IPC::Run3 parent: "
,
join
(
" "
, @{
$self
->get_app_cmd} ),
"\n"
,
);
$self
->{NeedNL} = 1;
}
sub
handle_app_exit {
my
$self
=
shift
;
$self
->_emit(
"\n"
)
if
$self
->{NeedNL} &&
$self
->{NeedNL} != 1;
$self
->_emit(
"IPC::Run3 total elapsed: "
,
_t(
$self
->get_app_cumulative_time ),
"\n"
);
$self
->_emit(
"IPC::Run3 calls to run3(): "
,
sprintf
(
"%10d"
,
$self
->get_run_count ),
"\n"
);
$self
->_emit(
"IPC::Run3 total spent in run3(): "
,
_t(
$self
->get_run_cumulative_time ),
_pct(
$self
->get_run_cumulative_time,
$self
->get_app_cumulative_time ),
", "
,
_r(
$self
->get_run_cumulative_time,
$self
->get_run_count ),
" per call"
,
"\n"
);
my
$exclusive
=
$self
->get_app_cumulative_time -
$self
->get_run_cumulative_time;
$self
->_emit(
"IPC::Run3 total spent not in run3(): "
,
_t(
$exclusive
),
_pct(
$exclusive
,
$self
->get_app_cumulative_time ),
"\n"
);
$self
->_emit(
"IPC::Run3 total spent in children: "
,
_t(
$self
->get_sys_cumulative_time ),
_pct(
$self
->get_sys_cumulative_time,
$self
->get_app_cumulative_time ),
", "
,
_r(
$self
->get_sys_cumulative_time,
$self
->get_run_count ),
" per call"
,
"\n"
);
my
$overhead
=
$self
->get_run_cumulative_time -
$self
->get_sys_cumulative_time;
$self
->_emit(
"IPC::Run3 total overhead: "
,
_t(
$overhead
),
_pct(
$overhead
,
$self
->get_sys_cumulative_time
),
", "
,
_r(
$overhead
,
$self
->get_run_count ),
" per call"
,
"\n"
);
}
sub
handle_run_exit {
my
$self
=
shift
;
my
$overhead
=
$self
->get_run_time -
$self
->get_sys_time;
$self
->_emit(
"\n"
)
if
$self
->{NeedNL} &&
$self
->{NeedNL} != 2;
$self
->{NeedNL} = 3;
$self
->_emit(
"IPC::Run3 child: "
,
join
(
" "
, @{
$self
->get_run_cmd} ),
"\n"
);
$self
->_emit(
"IPC::Run3 run3() : "
, _t(
$self
->get_run_time ),
"\n"
,
"IPC::Run3 child : "
, _t(
$self
->get_sys_time ),
"\n"
,
"IPC::Run3 overhead: "
, _t(
$overhead
),
_pct(
$overhead
,
$self
->get_sys_time ),
"\n"
);
}
1;