Profile of HTTP/Headers/ActionPack.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:10 2016

Filename | /usr/local/share/perl/5.18.2/HTTP/Headers/ActionPack.pm
Statements | Executed 900025 statements in 6.71s

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
100001 | 1 | 1 | 4.44s | 4.44s | HTTP::Headers::ActionPack::::newHTTP::Headers::ActionPack::new
100001 | 1 | 1 | 2.05s | 42.7s | HTTP::Headers::ActionPack::::create_headerHTTP::Headers::ActionPack::create_header
1 | 1 | 1 | 9µs | 41µs | HTTP::Headers::ActionPack::::BEGIN@13HTTP::Headers::ActionPack::BEGIN@13
1 | 1 | 1 | 8µs | 23µs | HTTP::Headers::ActionPack::::BEGIN@15HTTP::Headers::ActionPack::BEGIN@15
1 | 1 | 1 | 7µs | 10µs | HTTP::Headers::ActionPack::::BEGIN@11HTTP::Headers::ActionPack::BEGIN@11
1 | 1 | 1 | 7µs | 27µs | HTTP::Headers::ActionPack::::BEGIN@14HTTP::Headers::ActionPack::BEGIN@14
1 | 1 | 1 | 6µs | 6µs | HTTP::Headers::ActionPack::::BEGIN@2HTTP::Headers::ActionPack::BEGIN@2
1 | 1 | 1 | 6µs | 15µs | HTTP::Headers::ActionPack::::BEGIN@10HTTP::Headers::ActionPack::BEGIN@10
0 | 0 | 0 | 0s | 0s | HTTP::Headers::ActionPack::::_inflate_generic_requestHTTP::Headers::ActionPack::_inflate_generic_request
0 | 0 | 0 | 0s | 0s | HTTP::Headers::ActionPack::::_inflate_http_headersHTTP::Headers::ActionPack::_inflate_http_headers
0 | 0 | 0 | 0s | 0s | HTTP::Headers::ActionPack::::classesHTTP::Headers::ActionPack::classes
0 | 0 | 0 | 0s | 0s | HTTP::Headers::ActionPack::::createHTTP::Headers::ActionPack::create
0 | 0 | 0 | 0s | 0s | HTTP::Headers::ActionPack::::get_content_negotiatorHTTP::Headers::ActionPack::get_content_negotiator
0 | 0 | 0 | 0s | 0s | HTTP::Headers::ActionPack::::has_mappingHTTP::Headers::ActionPack::has_mapping
0 | 0 | 0 | 0s | 0s | HTTP::Headers::ActionPack::::inflateHTTP::Headers::ActionPack::inflate
0 | 0 | 0 | 0s | 0s | HTTP::Headers::ActionPack::::mappingsHTTP::Headers::ActionPack::mappings

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package HTTP::Headers::ActionPack;
2 |  |  |  |  | # spent 6µs within HTTP::Headers::ActionPack::BEGIN@2 which was called: # once (6µs+0s) by PONAPI::Server::BEGIN@11 at line 4 BEGIN {
3 | 1 | 4µs |  |  | $HTTP::Headers::ActionPack::AUTHORITY = 'cpan:STEVAN';
4 | 1 | 24µs | 1 | 6µs | } # spent 6µs making 1 call to HTTP::Headers::ActionPack::BEGIN@2
5 |  |  |  |  | {
6 | 2 | 900ns |  |  | $HTTP::Headers::ActionPack::VERSION = '0.09';
7 |  |  |  |  | }
8 |  |  |  |  | # ABSTRACT: HTTP Action, Adventure and Excitement
9 |  |  |  |  |
10 | 2 | 22µs | 2 | 25µs | # spent 15µs (6+10) within HTTP::Headers::ActionPack::BEGIN@10 which was called: # once (6µs+10µs) by PONAPI::Server::BEGIN@11 at line 10 use strict; # spent 15µs making 1 call to HTTP::Headers::ActionPack::BEGIN@10 # spent 10µs making 1 call to strict::import
11 | 2 | 22µs | 2 | 13µs | # spent 10µs (7+3) within HTTP::Headers::ActionPack::BEGIN@11 which was called: # once (7µs+3µs) by PONAPI::Server::BEGIN@11 at line 11 use warnings; # spent 10µs making 1 call to HTTP::Headers::ActionPack::BEGIN@11 # spent 3µs making 1 call to warnings::import
12 |  |  |  |  |
13 | 2 | 23µs | 2 | 72µs | # spent 41µs (9+31) within HTTP::Headers::ActionPack::BEGIN@13 which was called: # once (9µs+31µs) by PONAPI::Server::BEGIN@11 at line 13 use Scalar::Util qw[ blessed ]; # spent 41µs making 1 call to HTTP::Headers::ActionPack::BEGIN@13 # spent 31µs making 1 call to Exporter::import
14 | 2 | 22µs | 2 | 48µs | # spent 27µs (7+20) within HTTP::Headers::ActionPack::BEGIN@14 which was called: # once (7µs+20µs) by PONAPI::Server::BEGIN@11 at line 14 use Carp qw[ confess ]; # spent 27µs making 1 call to HTTP::Headers::ActionPack::BEGIN@14 # spent 20µs making 1 call to Exporter::import
15 | 2 | 470µs | 2 | 37µs | # spent 23µs (8+14) within HTTP::Headers::ActionPack::BEGIN@15 which was called: # once (8µs+14µs) by PONAPI::Server::BEGIN@11 at line 15 use Module::Runtime qw[ use_module ]; # spent 23µs making 1 call to HTTP::Headers::ActionPack::BEGIN@15 # spent 14µs making 1 call to Module::Runtime::import
16 |  |  |  |  |
17 | 1 | 2µs |  |  | my @DEFAULT_CLASSES = qw[
18 |  |  |  |  | HTTP::Headers::ActionPack::AcceptCharset
19 |  |  |  |  | HTTP::Headers::ActionPack::AcceptLanguage
20 |  |  |  |  | HTTP::Headers::ActionPack::AuthenticationInfo
21 |  |  |  |  | HTTP::Headers::ActionPack::Authorization
22 |  |  |  |  | HTTP::Headers::ActionPack::Authorization::Basic
23 |  |  |  |  | HTTP::Headers::ActionPack::Authorization::Digest
24 |  |  |  |  | HTTP::Headers::ActionPack::DateHeader
25 |  |  |  |  | HTTP::Headers::ActionPack::LinkHeader
26 |  |  |  |  | HTTP::Headers::ActionPack::LinkList
27 |  |  |  |  | HTTP::Headers::ActionPack::MediaType
28 |  |  |  |  | HTTP::Headers::ActionPack::MediaTypeList
29 |  |  |  |  | HTTP::Headers::ActionPack::PriorityList
30 |  |  |  |  | HTTP::Headers::ActionPack::WWWAuthenticate
31 |  |  |  |  | ];
32 |  |  |  |  |
33 | 1 | 7µs |  |  | my %DEFAULT_MAPPINGS = (
34 |  |  |  |  | 'link' => 'HTTP::Headers::ActionPack::LinkList',
35 |  |  |  |  | 'content-type' => 'HTTP::Headers::ActionPack::MediaType',
36 |  |  |  |  | 'accept' => 'HTTP::Headers::ActionPack::MediaTypeList',
37 |  |  |  |  | 'accept-charset' => 'HTTP::Headers::ActionPack::AcceptCharset',
38 |  |  |  |  | 'accept-encoding' => 'HTTP::Headers::ActionPack::PriorityList',
39 |  |  |  |  | 'accept-language' => 'HTTP::Headers::ActionPack::AcceptLanguage',
40 |  |  |  |  | 'date' => 'HTTP::Headers::ActionPack::DateHeader',
41 |  |  |  |  | 'client-date' => 'HTTP::Headers::ActionPack::DateHeader', # added by LWP
42 |  |  |  |  | 'expires' => 'HTTP::Headers::ActionPack::DateHeader',
43 |  |  |  |  | 'last-modified' => 'HTTP::Headers::ActionPack::DateHeader',
44 |  |  |  |  | 'if-unmodified-since' => 'HTTP::Headers::ActionPack::DateHeader',
45 |  |  |  |  | 'if-modified-since' => 'HTTP::Headers::ActionPack::DateHeader',
46 |  |  |  |  | 'www-authenticate' => 'HTTP::Headers::ActionPack::WWWAuthenticate',
47 |  |  |  |  | 'authentication-info' => 'HTTP::Headers::ActionPack::AuthenticationInfo',
48 |  |  |  |  | 'authorization' => 'HTTP::Headers::ActionPack::Authorization',
49 |  |  |  |  | );
50 |  |  |  |  |
51 |  |  |  |  | # spent 4.44s within HTTP::Headers::ActionPack::new which was called 100001 times, avg 44µs/call: # 100001 times (4.44s+0s) by PONAPI::Server::_ponapi_check_headers at line 219 of lib/PONAPI/Server.pm, avg 44µs/call sub new {
52 | 100001 | 64.3ms |  |  | my $class = shift;
53 | 100001 | 112ms |  |  | my %additional = @_;
54 | 100001 | 1.75s |  |  | my %mappings = ( %DEFAULT_MAPPINGS, %additional );
55 | 100001 | 1.86s |  |  | my %classes = map { $_ => undef } ( @DEFAULT_CLASSES, values %additional );
56 |  |  |  |  |
57 | 100001 | 1.05s |  |  | bless {
58 |  |  |  |  | mappings => \%mappings,
59 |  |  |  |  | classes => \%classes
60 |  |  |  |  | } => $class;
61 |  |  |  |  | }
62 |  |  |  |  |
63 |  |  |  |  | sub mappings { (shift)->{'mappings'} }
64 |  |  |  |  | sub classes { keys %{ (shift)->{'classes'} } }
65 |  |  |  |  |
66 |  |  |  |  | sub has_mapping {
67 |  |  |  |  | my ($self, $header_name) = @_;
68 |  |  |  |  | exists $self->{'mappings'}->{ lc $header_name } ? 1 : 0
69 |  |  |  |  | }
70 |  |  |  |  |
71 |  |  |  |  | sub get_content_negotiator {
72 |  |  |  |  | use_module('HTTP::Headers::ActionPack::ContentNegotiation')->new( shift );
73 |  |  |  |  | }
74 |  |  |  |  |
75 |  |  |  |  | sub create {
76 |  |  |  |  | my ($self, $class_name, $args) = @_;
77 |  |  |  |  |
78 |  |  |  |  | my $class = exists $self->{'classes'}->{ $class_name }
79 |  |  |  |  | ? $class_name
80 |  |  |  |  | : exists $self->{'classes'}->{ __PACKAGE__ . '::' . $class_name }
81 |  |  |  |  | ? __PACKAGE__ . '::' . $class_name
82 |  |  |  |  | : undef;
83 |  |  |  |  |
84 |  |  |  |  | (defined $class)
85 |  |  |  |  | || confess "Could not find class '$class_name' (or 'HTTP::Headers::ActionPack::$class_name')";
86 |  |  |  |  |
87 |  |  |  |  | ref $args
88 |  |  |  |  | ? use_module( $class )->new( @$args )
89 |  |  |  |  | : use_module( $class )->new_from_string( $args );
90 |  |  |  |  | }
91 |  |  |  |  |
92 |  |  |  |  | # spent 42.7s (2.05+40.7) within HTTP::Headers::ActionPack::create_header which was called 100001 times, avg 427µs/call: # 100001 times (2.05s+40.7s) by PONAPI::Server::_ponapi_check_headers at line 222 of lib/PONAPI/Server.pm, avg 427µs/call sub create_header {
93 | 100001 | 95.6ms |  |  | my ($self, $header_name, $header_value) = @_;
94 |  |  |  |  |
95 | 100001 | 151ms |  |  | my $class = $self->{'mappings'}->{ lc $header_name };
96 |  |  |  |  |
97 | 100001 | 49.9ms |  |  | (defined $class)
98 |  |  |  |  | || confess "Could not find mapping for '$header_name'";
99 |  |  |  |  |
100 | 100001 | 1.57s | 200002 | 40.7s | ref $header_value # spent 33.2s making 100001 calls to HTTP::Headers::ActionPack::PriorityList::new_from_string, avg 332µs/call # spent 7.49s making 100001 calls to Module::Runtime::use_module, avg 75µs/call
101 |  |  |  |  | ? use_module( $class )->new( @$header_value )
102 |  |  |  |  | : use_module( $class )->new_from_string( $header_value );
103 |  |  |  |  | }
104 |  |  |  |  |
105 |  |  |  |  | sub inflate {
106 |  |  |  |  | my $self = shift;
107 |  |  |  |  | return $self->_inflate_http_headers( @_ )
108 |  |  |  |  | if $_[0]->isa('HTTP::Headers');
109 |  |  |  |  | return $self->_inflate_generic_request( @_ )
110 |  |  |  |  | if $_[0]->isa('HTTP::Request')
111 |  |  |  |  | || $_[0]->isa('Plack::Request')
112 |  |  |  |  | || $_[0]->isa('Web::Request');
113 |  |  |  |  | confess "I don't know how to inflate '$_[0]'";
114 |  |  |  |  | }
115 |  |  |  |  |
116 |  |  |  |  | sub _inflate_http_headers {
117 |  |  |  |  | my ($self, $http_headers) = @_;
118 |  |  |  |  | foreach my $header ( keys %{ $self->{'mappings'} } ) {
119 |  |  |  |  | if ( my $old = $http_headers->header( $header ) ) {
120 |  |  |  |  | $http_headers->header( $header => $self->create_header( $header, $old ) )
121 |  |  |  |  | unless blessed $old && $old->isa('HTTP::Headers::ActionPack::Core::Base');
122 |  |  |  |  | }
123 |  |  |  |  | }
124 |  |  |  |  | return $http_headers;
125 |  |  |  |  | }
126 |  |  |  |  |
127 |  |  |  |  | sub _inflate_generic_request {
128 |  |  |  |  | my ($self, $request) = @_;
129 |  |  |  |  | $self->_inflate_http_headers( $request->headers );
130 |  |  |  |  | return $request;
131 |  |  |  |  | }
132 |  |  |  |  |
133 | 1 | 5µs |  |  | 1;
134 |  |  |  |  |
135 |  |  |  |  | __END__