[Catalyst-dev] [Patch] Better $elapsed==0 handling.
Emanuele Zeppieri
ema_zep at libero.it
Wed Jul 18 19:14:33 GMT 2007
Trivial, nonetheless improving.
Line 1339 in Catalyst.pm (from Catalyst-Runtime-5.7007) reads:
my $av =3D sprintf '%.3f', ( $elapsed =3D=3D 0 ? '??' : ( 1 / $elapsed ) );
which of course triggers the warning:
Argument "??" isn't numeric in sprintf
when $elapsed=3D=3D0 is true.
It also causes $av to be set to 0.000, which is a misleading value, =
given the situation.
The obvious correction is to substitute the above mentioned line with:
my $av =3D $elapsed =3D=3D 0 ? '??' : sprintf '%.3f', 1 / $elapsed;
Patch (against Catalyst.pm in trunk -- Revision 6575) attached, if =
necessary.
Cheers,
Emanuele.
-------------- next part --------------
--- Catalyst.pm 2007-07-18 19:34:59.158123300 +0200
+++ Catalyst.pm.new 2007-07-18 19:37:16.009923300 +0200
@@ -1353,7 +1353,7 @@
=
if ($c->debug) {
my $elapsed =3D sprintf '%f', tv_interval($c->stats->getNodeValue);
- my $av =3D sprintf '%.3f', ( $elapsed =3D=3D 0 ? '??' : ( 1 / $ela=
psed ) );
+ my $av =3D $elapsed =3D=3D 0 ? '??' : sprintf '%.3f', 1 / $elapsed;
=
my $t =3D Text::SimpleTable->new( [ 62, 'Action' ], [ 9, 'Time' ] =
);
$c->stats->traverse(
More information about the Catalyst-dev
mailing list