← Index
NYTProf Performance Profile   « line view »
For script/ponapi
  Run on Wed Feb 10 15:51:26 2016
Reported on Thu Feb 11 09:43:09 2016

Filename/usr/local/share/perl/5.18.2/Plack/Middleware/MethodOverride.pm
StatementsExecuted 400032 statements in 1.59s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
100001112.28s875sPlack::Middleware::MethodOverride::::callPlack::Middleware::MethodOverride::call
1111.91ms34.5msPONAPI::CLI::RunServer::::BEGIN@4.20 PONAPI::CLI::RunServer::BEGIN@4.20
111144µs174µsPlack::Middleware::MethodOverride::::newPlack::Middleware::MethodOverride::new
11133µs33µsPONAPI::CLI::RunServer::::BEGIN@1 PONAPI::CLI::RunServer::BEGIN@1
11115µs26µsPONAPI::CLI::RunServer::::BEGIN@3 PONAPI::CLI::RunServer::BEGIN@3
11114µs41µsPONAPI::CLI::RunServer::::BEGIN@2 PONAPI::CLI::RunServer::BEGIN@2
11111µs11µsPlack::Middleware::MethodOverride::::headerPlack::Middleware::MethodOverride::header
11110µs1.03msPlack::Middleware::MethodOverride::::BEGIN@10Plack::Middleware::MethodOverride::BEGIN@10
1118µs24µsPlack::Middleware::MethodOverride::::BEGIN@29Plack::Middleware::MethodOverride::BEGIN@29
1116µs17µsPlack::Middleware::MethodOverride::::BEGIN@11Plack::Middleware::MethodOverride::BEGIN@11
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1278µs133µs
# spent 33µs within PONAPI::CLI::RunServer::BEGIN@1 which was called: # once (33µs+0s) by PONAPI::CLI::RunServer::BEGIN@8 at line 1
use 5.008001;
# spent 33µs making 1 call to PONAPI::CLI::RunServer::BEGIN@1
2241µs267µs
# spent 41µs (14+27) within PONAPI::CLI::RunServer::BEGIN@2 which was called: # once (14µs+27µs) by PONAPI::CLI::RunServer::BEGIN@8 at line 2
use strict;
# spent 41µs making 1 call to PONAPI::CLI::RunServer::BEGIN@2 # spent 27µs making 1 call to strict::import
3240µs238µs
# spent 26µs (15+12) within PONAPI::CLI::RunServer::BEGIN@3 which was called: # once (15µs+12µs) by PONAPI::CLI::RunServer::BEGIN@8 at line 3
use warnings;
# spent 26µs making 1 call to PONAPI::CLI::RunServer::BEGIN@3 # spent 12µs making 1 call to warnings::import
42152µs134.5ms
# spent 34.5ms (1.91+32.6) within PONAPI::CLI::RunServer::BEGIN@4.20 which was called: # once (1.91ms+32.6ms) by PONAPI::CLI::RunServer::BEGIN@8 at line 4
use Plack::Request ();
# spent 34.5ms making 1 call to PONAPI::CLI::RunServer::BEGIN@4.20
5
6package Plack::Middleware::MethodOverride;
711µs$Plack::Middleware::MethodOverride::VERSION = '0.15';
8# ABSTRACT: Override REST methods to Plack apps via POST
9
10232µs22.04ms
# spent 1.03ms (10µs+1.02) within Plack::Middleware::MethodOverride::BEGIN@10 which was called: # once (10µs+1.02ms) by PONAPI::CLI::RunServer::BEGIN@8 at line 10
use parent 'Plack::Middleware';
# spent 1.03ms making 1 call to Plack::Middleware::MethodOverride::BEGIN@10 # spent 1.02ms making 1 call to parent::import
112111µs228µs
# spent 17µs (6+11) within Plack::Middleware::MethodOverride::BEGIN@11 which was called: # once (6µs+11µs) by PONAPI::CLI::RunServer::BEGIN@8 at line 11
use Plack::Util::Accessor 'param';
# spent 17µs making 1 call to Plack::Middleware::MethodOverride::BEGIN@11 # spent 11µs making 1 call to Plack::Util::Accessor::import
12
1317µsmy %allowed_method = map { $_ => undef } qw(GET HEAD PUT DELETE OPTIONS TRACE CONNECT PATCH);
14
15
# spent 174µs (144+30) within Plack::Middleware::MethodOverride::new which was called: # once (144µs+30µs) by Plack::Middleware::wrap at line 14 of Plack/Middleware.pm
sub new {
1612µs my $class = shift;
17110µs119µs my $self = $class->SUPER::new(@_);
# spent 19µs making 1 call to Plack::Component::new
181114µs $self->{param} = 'x-tunneled-method' unless exists $self->{param};
1912µs $self->{header} = 'X-HTTP-Method-Override' unless exists $self->{header};
2014µs111µs $self->header($self->{header}); # munge it
# spent 11µs making 1 call to Plack::Middleware::MethodOverride::header
21112µs return $self;
22}
23
24
# spent 875s (2.28+872) within Plack::Middleware::MethodOverride::call which was called 100001 times, avg 8.75ms/call: # 100001 times (2.28s+872s) by Plack::Component::__ANON__[/usr/local/share/perl/5.18.2/Plack/Component.pm:50] at line 50 of Plack/Component.pm, avg 8.75ms/call
sub call {
2510000180.5ms my ($self, $env) = @_;
26100001296ms my $meth = $env->{'plack.original_request_method'} = $env->{REQUEST_METHOD};
27
28100001167ms if ($meth and uc $meth eq 'POST') {
292133µs239µs
# spent 24µs (8+16) within Plack::Middleware::MethodOverride::BEGIN@29 which was called: # once (8µs+16µs) by PONAPI::CLI::RunServer::BEGIN@8 at line 29
no warnings 'uninitialized';
# spent 24µs making 1 call to Plack::Middleware::MethodOverride::BEGIN@29 # spent 16µs making 1 call to warnings::unimport
30 my $override = uc (
31 $env->{$self->header}
32 or $env->{QUERY_STRING} && Plack::Request->new($env)->query_parameters->{$self->param}
33 );
34 $env->{REQUEST_METHOD} = $override if exists $allowed_method{$override};
35 }
36
371000011.05s200002872s $self->app->($env);
# spent 872s making 100001 calls to Plack::Component::__ANON__[Plack/Component.pm:50], avg 8.72ms/call # spent 232ms making 100001 calls to Plack::Util::Accessor::__ANON__[Plack/Util/Accessor.pm:19], avg 2µs/call
38}
39
40
# spent 11µs within Plack::Middleware::MethodOverride::header which was called: # once (11µs+0s) by Plack::Middleware::MethodOverride::new at line 20
sub header {
411500ns my $self = shift;
42
431700ns return $self->{header} if not @_;
441500ns return $self->{header} = '' if not $_[0];
45
4615µs (my $key = 'HTTP_'.$_[0]) =~ tr/-a-z/_A-Z/;
4719µs return $self->{header} = $key;
48}
49
5014µs1;
51
52__END__