Profile of Plack/Middleware/MethodOverride.pm

← 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
Statements | Executed 400032 statements in 1.59s

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
100001 | 1 | 1 | 2.28s | 875s | Plack::Middleware::MethodOverride::::callPlack::Middleware::MethodOverride::call
1 | 1 | 1 | 1.91ms | 34.5ms | PONAPI::CLI::RunServer::::BEGIN@4.20 PONAPI::CLI::RunServer::BEGIN@4.20
1 | 1 | 1 | 144µs | 174µs | Plack::Middleware::MethodOverride::::newPlack::Middleware::MethodOverride::new
1 | 1 | 1 | 33µs | 33µs | PONAPI::CLI::RunServer::::BEGIN@1 PONAPI::CLI::RunServer::BEGIN@1
1 | 1 | 1 | 15µs | 26µs | PONAPI::CLI::RunServer::::BEGIN@3 PONAPI::CLI::RunServer::BEGIN@3
1 | 1 | 1 | 14µs | 41µs | PONAPI::CLI::RunServer::::BEGIN@2 PONAPI::CLI::RunServer::BEGIN@2
1 | 1 | 1 | 11µs | 11µs | Plack::Middleware::MethodOverride::::headerPlack::Middleware::MethodOverride::header
1 | 1 | 1 | 10µs | 1.03ms | Plack::Middleware::MethodOverride::::BEGIN@10Plack::Middleware::MethodOverride::BEGIN@10
1 | 1 | 1 | 8µs | 24µs | Plack::Middleware::MethodOverride::::BEGIN@29Plack::Middleware::MethodOverride::BEGIN@29
1 | 1 | 1 | 6µs | 17µs | Plack::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
--- | --- | --- | --- | --- | ---
1 | 2 | 78µs | 1 | 33µ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
2 | 2 | 41µs | 2 | 67µ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
3 | 2 | 40µs | 2 | 38µ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
4 | 2 | 152µs | 1 | 34.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 |  |  |  |  |
6 |  |  |  |  | package Plack::Middleware::MethodOverride;
7 | 1 | 1µs |  |  | $Plack::Middleware::MethodOverride::VERSION = '0.15';
8 |  |  |  |  | # ABSTRACT: Override REST methods to Plack apps via POST
9 |  |  |  |  |
10 | 2 | 32µs | 2 | 2.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
11 | 2 | 111µs | 2 | 28µ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 |  |  |  |  |
13 | 1 | 7µs |  |  | my %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 {
16 | 1 | 2µs |  |  | my $class = shift;
17 | 1 | 10µs | 1 | 19µs | my $self = $class->SUPER::new(@_); # spent 19µs making 1 call to Plack::Component::new
18 | 1 | 114µs |  |  | $self->{param} = 'x-tunneled-method' unless exists $self->{param};
19 | 1 | 2µs |  |  | $self->{header} = 'X-HTTP-Method-Override' unless exists $self->{header};
20 | 1 | 4µs | 1 | 11µs | $self->header($self->{header}); # munge it # spent 11µs making 1 call to Plack::Middleware::MethodOverride::header
21 | 1 | 12µ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 {
25 | 100001 | 80.5ms |  |  | my ($self, $env) = @_;
26 | 100001 | 296ms |  |  | my $meth = $env->{'plack.original_request_method'} = $env->{REQUEST_METHOD};
27 |  |  |  |  |
28 | 100001 | 167ms |  |  | if ($meth and uc $meth eq 'POST') {
29 | 2 | 133µs | 2 | 39µ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 |  |  |  |  |
37 | 100001 | 1.05s | 200002 | 872s | $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 {
41 | 1 | 500ns |  |  | my $self = shift;
42 |  |  |  |  |
43 | 1 | 700ns |  |  | return $self->{header} if not @_;
44 | 1 | 500ns |  |  | return $self->{header} = '' if not $_[0];
45 |  |  |  |  |
46 | 1 | 5µs |  |  | (my $key = 'HTTP_'.$_[0]) =~ tr/-a-z/_A-Z/;
47 | 1 | 9µs |  |  | return $self->{header} = $key;
48 |  |  |  |  | }
49 |  |  |  |  |
50 | 1 | 4µs |  |  | 1;
51 |  |  |  |  |
52 |  |  |  |  | __END__