X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=9530a040a6e3bf77e1c4e2afff3298e498cc97df;hb=af2ab6a0a923fc8f2472efaf494fc5287db92226;hp=c4f4b0527ca412f450df8ffc9acd3231e53f34d8;hpb=89546294537c1453e324c14d987ef92268d92f42;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index c4f4b05..9530a04 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -18,6 +18,20 @@ use URI; use Scalar::Util qw/weaken/; use attributes; +# For PAR +require Catalyst::Helper; +require Catalyst::PAR; +require Catalyst::Build; +require Catalyst::Test; + +require Catalyst::Engine::HTTP; +require Catalyst::Engine::CGI; +require Catalyst::Engine::FastCGI; + +require Catalyst::Controller; +require Catalyst::Model; +require Catalyst::View; + __PACKAGE__->mk_accessors( qw/counter request response state action stack namespace/ ); @@ -43,7 +57,7 @@ our $DETACH = "catalyst_detach\n"; require Module::Pluggable::Fast; # Helper script generation -our $CATALYST_SCRIPT_GEN = 11; +our $CATALYST_SCRIPT_GEN = 14; __PACKAGE__->mk_classdata($_) for qw/components arguments dispatcher engine log dispatcher_class @@ -54,7 +68,7 @@ __PACKAGE__->engine_class('Catalyst::Engine::CGI'); __PACKAGE__->request_class('Catalyst::Request'); __PACKAGE__->response_class('Catalyst::Response'); -our $VERSION = '5.53'; +our $VERSION = '5.57'; sub import { my ( $class, @arguments ) = @_; @@ -847,24 +861,6 @@ These methods are not meant to be used by end users. =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. @@ -944,22 +940,19 @@ sub execute { $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 = $@ ) { @@ -1129,8 +1122,9 @@ sub handle_request { }; 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 ) ); @@ -1496,8 +1490,7 @@ qq/Couldn't instantiate component "$component", "new() didn't return a object"/ return $instance; }; - eval { - Module::Pluggable::Fast->import( + eval "package $class;\n" . q!Module::Pluggable::Fast->import( name => '_catalyst_components', search => [ "$class\::Controller", "$class\::C", @@ -1506,7 +1499,7 @@ qq/Couldn't instantiate component "$component", "new() didn't return a object"/ ], callback => $callback ); - }; + !; if ( my $error = $@ ) {