require Module::Pluggable::Fast;
# Helper script generation
-our $CATALYST_SCRIPT_GEN = 11;
+our $CATALYST_SCRIPT_GEN = 12;
__PACKAGE__->mk_classdata($_)
for qw/components arguments dispatcher engine log dispatcher_class
__PACKAGE__->request_class('Catalyst::Request');
__PACKAGE__->response_class('Catalyst::Response');
-our $VERSION = '5.52';
+our $VERSION = '5.56';
sub import {
my ( $class, @arguments ) = @_;
=over 4
-=item $c->benchmark( $coderef )
-
-Takes a coderef with arguments and returns elapsed time as float.
-
- my ( $elapsed, $status ) = $c->benchmark( sub { return 1 } );
- $c->log->info( sprintf "Processing took %f seconds", $elapsed );
-
-=cut
-
-sub benchmark {
- my $c = shift;
- my $code = shift;
- my $time = [gettimeofday];
- my @return = &$code(@_);
- my $elapsed = tv_interval $time;
- return wantarray ? ( $elapsed, @return ) : $elapsed;
-}
-
=item $c->components
Returns a hash of components.
$action = "-> $action" if $callsub =~ /forward$/;
}
push( @{ $c->stack }, $code );
- eval {
- if ( $c->debug )
+ my $elapsed = 0;
+ my $start = 0;
+ $start = [gettimeofday] if $c->debug;
+ eval { $c->state( &$code( $class, $c, @{ $c->req->args } ) || 0 ) };
+ $elapsed = tv_interval($start) if $c->debug;
+
+ if ( $c->debug ) {
+ unless ( ( $code->name =~ /^_.*/ )
+ && ( !$c->config->{show_internal_actions} ) )
{
- my ( $elapsed, @state ) =
- $c->benchmark( $code, $class, $c, @{ $c->req->args } );
- unless ( ( $code->name =~ /^_.*/ )
- && ( !$c->config->{show_internal_actions} ) )
- {
- push @{ $c->{stats} }, [ $action, sprintf( '%fs', $elapsed ) ];
- }
- $c->state(@state);
- }
- else {
- $c->state( &$code( $class, $c, @{ $c->req->args } ) || 0 );
+ push @{ $c->{stats} }, [ $action, sprintf( '%fs', $elapsed ) ];
}
- };
+ }
pop( @{ $c->stack } );
if ( my $error = $@ ) {
};
if ( $class->debug ) {
- my $elapsed;
- ( $elapsed, $status ) = $class->benchmark($handler);
+ my $start = [gettimeofday];
+ $status = &$handler;
+ my $elapsed = tv_interval $start;
$elapsed = sprintf '%f', $elapsed;
my $av = sprintf '%.3f',
( $elapsed == 0 ? '??' : ( 1 / $elapsed ) );
return $instance;
};
- eval {
- Module::Pluggable::Fast->import(
+ eval "package $class;\n" . q!Module::Pluggable::Fast->import(
name => '_catalyst_components',
search => [
"$class\::Controller", "$class\::C",
],
callback => $callback
);
- };
+ !;
if ( my $error = $@ ) {