X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=96ad9a5bea25dc748eebe56b56e540b011f8137b;hb=51bc4dd200c2363e7d4e86670d46a31045214e8c;hp=e63fb98dc838d8e5407665ba252a70ab0ec789ee;hpb=dc5f035ee51a9833b5340e3ee597f5722263042f;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index e63fb98..96ad9a5 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -65,7 +65,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.7011'; +our $VERSION = '5.7012'; sub import { my ( $class, @arguments ) = @_; @@ -1266,24 +1266,35 @@ sub _stats_start_execute { } } + my $uid = "$code" . $c->counter->{"$code"}; + # is this a root-level call or a forwarded call? if ( $callsub =~ /forward$/ ) { # forward, locate the caller if ( my $parent = $c->stack->[-1] ) { - $c->stats->profile(begin => $action, - parent => "$parent" . $c->counter->{"$parent"}); + $c->stats->profile( + begin => $action, + parent => "$parent" . $c->counter->{"$parent"}, + uid => $uid, + ); } else { # forward with no caller may come from a plugin - $c->stats->profile(begin => $action); + $c->stats->profile( + begin => $action, + uid => $uid, + ); } } else { - + # root-level call - $c->stats->profile(begin => $action); + $c->stats->profile( + begin => $action, + uid => $uid, + ); } return $action; @@ -1291,7 +1302,7 @@ sub _stats_start_execute { sub _stats_finish_execute { my ( $c, $info ) = @_; - $c->stats->profile(end => $info); + $c->stats->profile( end => $info ); } =head2 $c->_localize_fields( sub { }, \%keys ); @@ -1347,8 +1358,8 @@ sub finalize { $c->finalize_body; } - if ($c->use_stats) { - my $elapsed = tv_interval($c->stats->getNodeValue); + if ($c->use_stats) { + my $elapsed = sprintf '%f', $c->stats->elapsed; my $av = $elapsed == 0 ? '??' : sprintf '%.3f', 1 / $elapsed; $c->log->info( "Request took ${elapsed}s ($av/s)\n" . $c->stats->report . "\n" ); @@ -1421,6 +1432,7 @@ sub finalize_headers { } } else { + # everything should be bytes at this point, but just in case $c->response->content_length( bytes::length( $c->response->body ) ); } } @@ -2122,9 +2134,9 @@ sub setup_stats { my $env = Catalyst::Utils::env_value( $class, 'STATS' ); if ( defined($env) ? $env : ($stats || $class->debug ) ) { - no strict 'refs'; - *{"$class\::use_stats"} = sub { 1 }; - $class->log->debug('Statistics enabled'); + no strict 'refs'; + *{"$class\::use_stats"} = sub { 1 }; + $class->log->debug('Statistics enabled'); } }