← 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/Plack/Response.pm
StatementsExecuted 5700075 statements in 14.9s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
100001113.83s13.9sPlack::Response::::finalizePlack::Response::finalize
300003112.32s2.89sPlack::Response::::__ANON__[:96]Plack::Response::__ANON__[:96]
500005521.67s2.20sPlack::Response::::headersPlack::Response::headers
100001111.34s3.42sPlack::Response::::content_lengthPlack::Response::content_length
100001111.24s1.67sPlack::Response::::newPlack::Response::new
100001111.00s1.14sPlack::Response::::_bodyPlack::Response::_body
100001111.00s4.35sPlack::Response::::headerPlack::Response::header
10000111952ms1.51sPlack::Response::::content_typePlack::Response::content_type
10000111831ms1.18sPlack::Response::::_finalize_cookiesPlack::Response::_finalize_cookies
10000111741ms1.09sPlack::Response::::contentPlack::Response::content
60000621572ms572msPlack::Response::::CORE:substPlack::Response::CORE:subst (opcode)
10000111349ms349msPlack::Response::::cookiesPlack::Response::cookies
111641µs854µsPlack::Response::::BEGIN@8Plack::Response::BEGIN@8
11118µs18µsPlack::Response::::BEGIN@10Plack::Response::BEGIN@10
11110µs24µsPlack::Response::::BEGIN@6Plack::Response::BEGIN@6
11110µs19µsPlack::Response::::BEGIN@2Plack::Response::BEGIN@2
1117µs10µsPlack::Response::::BEGIN@3Plack::Response::BEGIN@3
1113µs3µsPlack::Response::::BEGIN@9Plack::Response::BEGIN@9
1113µs3µsPlack::Response::::BEGIN@11Plack::Response::BEGIN@11
1113µs3µsPlack::Response::::BEGIN@7Plack::Response::BEGIN@7
0000s0sPlack::Response::::__ANON__[:109]Plack::Response::__ANON__[:109]
0000s0sPlack::Response::::codePlack::Response::code
0000s0sPlack::Response::::content_encodingPlack::Response::content_encoding
0000s0sPlack::Response::::locationPlack::Response::location
0000s0sPlack::Response::::redirectPlack::Response::redirect
0000s0sPlack::Response::::to_appPlack::Response::to_app
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Plack::Response;
2219µs228µs
# spent 19µs (10+9) within Plack::Response::BEGIN@2 which was called: # once (10µs+9µs) by PONAPI::Server::BEGIN@10 at line 2
use strict;
# spent 19µs making 1 call to Plack::Response::BEGIN@2 # spent 9µs making 1 call to strict::import
3230µs213µs
# spent 10µs (7+3) within Plack::Response::BEGIN@3 which was called: # once (7µs+3µs) by PONAPI::Server::BEGIN@10 at line 3
use warnings;
# spent 10µs making 1 call to Plack::Response::BEGIN@3 # spent 3µs making 1 call to warnings::import
41400nsour $VERSION = '1.0037';
5
6220µs238µs
# spent 24µs (10+14) within Plack::Response::BEGIN@6 which was called: # once (10µs+14µs) by PONAPI::Server::BEGIN@10 at line 6
use Plack::Util::Accessor qw(body status);
# spent 24µs making 1 call to Plack::Response::BEGIN@6 # spent 14µs making 1 call to Plack::Util::Accessor::import
7216µs13µs
# spent 3µs within Plack::Response::BEGIN@7 which was called: # once (3µs+0s) by PONAPI::Server::BEGIN@10 at line 7
use Carp ();
# spent 3µs making 1 call to Plack::Response::BEGIN@7
8277µs1854µs
# spent 854µs (641+212) within Plack::Response::BEGIN@8 which was called: # once (641µs+212µs) by PONAPI::Server::BEGIN@10 at line 8
use Cookie::Baker ();
# spent 854µs making 1 call to Plack::Response::BEGIN@8
9244µs13µs
# spent 3µs within Plack::Response::BEGIN@9 which was called: # once (3µs+0s) by PONAPI::Server::BEGIN@10 at line 9
use Scalar::Util ();
# spent 3µs making 1 call to Plack::Response::BEGIN@9
10227µs118µs
# spent 18µs within Plack::Response::BEGIN@10 which was called: # once (18µs+0s) by PONAPI::Server::BEGIN@10 at line 10
use HTTP::Headers::Fast;
# spent 18µs making 1 call to Plack::Response::BEGIN@10
112583µs13µs
# spent 3µs within Plack::Response::BEGIN@11 which was called: # once (3µs+0s) by PONAPI::Server::BEGIN@10 at line 11
use URI::Escape ();
# spent 3µs making 1 call to Plack::Response::BEGIN@11
12
13sub code { shift->status(@_) }
14100001501ms100001349ms
# spent 1.09s (741ms+349ms) within Plack::Response::content which was called 100001 times, avg 11µs/call: # 100001 times (741ms+349ms) by PONAPI::Server::_response at line 368 of lib/PONAPI/Server.pm, avg 11µs/call
sub content { shift->body(@_) }
# spent 349ms making 100001 calls to Plack::Util::Accessor::__ANON__[Plack/Util/Accessor.pm:19], avg 3µs/call
15
16
# spent 1.67s (1.24+434ms) within Plack::Response::new which was called 100001 times, avg 17µs/call: # 100001 times (1.24s+434ms) by PONAPI::Server::_response at line 358 of lib/PONAPI/Server.pm, avg 17µs/call
sub new {
1710000172.6ms my($class, $rc, $headers, $content) = @_;
18
19100001131ms my $self = bless {}, $class;
20100001276ms100001434ms $self->status($rc) if defined $rc;
# spent 434ms making 100001 calls to Plack::Util::Accessor::__ANON__[Plack/Util/Accessor.pm:19], avg 4µs/call
2110000143.9ms $self->headers($headers) if defined $headers;
2210000136.1ms $self->body($content) if defined $content;
23
24100001453ms $self;
25}
26
27
# spent 2.20s (1.67+533ms) within Plack::Response::headers which was called 500005 times, avg 4µs/call: # 100001 times (1.13s+533ms) by PONAPI::Server::_response at line 360 of lib/PONAPI/Server.pm, avg 17µs/call # 100001 times (175ms+0s) by Plack::Response::header at line 53, avg 2µs/call # 100001 times (140ms+0s) by Plack::Response::content_length at line 56, avg 1µs/call # 100001 times (120ms+0s) by Plack::Response::finalize at line 89, avg 1µs/call # 100001 times (105ms+0s) by Plack::Response::content_type at line 60, avg 1µs/call
sub headers {
2850000591.6ms my $self = shift;
29
30500005155ms if (@_) {
3110000126.2ms my $headers = shift;
32100001136ms if (ref $headers eq 'ARRAY') {
3310000185.5ms Carp::carp("Odd number of headers") if @$headers % 2 != 0;
34100001294ms100001533ms $headers = HTTP::Headers::Fast->new(@$headers);
# spent 533ms making 100001 calls to HTTP::Headers::Fast::new, avg 5µs/call
35 } elsif (ref $headers eq 'HASH') {
36 $headers = HTTP::Headers::Fast->new(%$headers);
37 }
38100001412ms return $self->{headers} = $headers;
39 } else {
404000041.61s return $self->{headers} ||= HTTP::Headers::Fast->new();
41 }
42}
43
44
# spent 349ms within Plack::Response::cookies which was called 100001 times, avg 3µs/call: # 100001 times (349ms+0s) by Plack::Response::_finalize_cookies at line 127, avg 3µs/call
sub cookies {
4510000142.7ms my $self = shift;
4610000159.0ms if (@_) {
47 $self->{cookies} = shift;
48 } else {
49100001565ms return $self->{cookies} ||= +{ };
50 }
51}
52
53100001653ms2000023.35s
# spent 4.35s (1.00+3.35) within Plack::Response::header which was called 100001 times, avg 43µs/call: # 100001 times (1.00s+3.35s) by PONAPI::Server::_response at line 361 of lib/PONAPI/Server.pm, avg 43µs/call
sub header { shift->headers->header(@_) } # shortcut
# spent 3.17s making 100001 calls to HTTP::Headers::Fast::header, avg 32µs/call # spent 175ms making 100001 calls to Plack::Response::headers, avg 2µs/call
54
55
# spent 3.42s (1.34+2.08) within Plack::Response::content_length which was called 100001 times, avg 34µs/call: # 100001 times (1.34s+2.08s) by PONAPI::Server::_response at line 366 of lib/PONAPI/Server.pm, avg 34µs/call
sub content_length {
56100001700ms2000022.08s shift->headers->content_length(@_);
# spent 1.94s making 100001 calls to HTTP::Headers::Fast::__ANON__[HTTP/Headers/Fast.pm:561], avg 19µs/call # spent 140ms making 100001 calls to Plack::Response::headers, avg 1µs/call
57}
58
59
# spent 1.51s (952ms+555ms) within Plack::Response::content_type which was called 100001 times, avg 15µs/call: # 100001 times (952ms+555ms) by PONAPI::Server::_response at line 367 of lib/PONAPI/Server.pm, avg 15µs/call
sub content_type {
60100001669ms200002555ms shift->headers->content_type(@_);
# spent 450ms making 100001 calls to HTTP::Headers::Fast::content_type, avg 5µs/call # spent 105ms making 100001 calls to Plack::Response::headers, avg 1µs/call
61}
62
63sub content_encoding {
64 shift->headers->content_encoding(@_);
65}
66
67sub location {
68 my $self = shift;
69 return $self->headers->header('Location' => @_);
70}
71
72sub redirect {
73 my $self = shift;
74
75 if (@_) {
76 my $url = shift;
77 my $status = shift || 302;
78 $self->location($url);
79 $self->status($status);
80 }
81
82 return $self->location;
83}
84
85
# spent 13.9s (3.83+10.0) within Plack::Response::finalize which was called 100001 times, avg 139µs/call: # 100001 times (3.83s+10.0s) by PONAPI::Server::_response at line 371 of lib/PONAPI/Server.pm, avg 139µs/call
sub finalize {
8610000139.3ms my $self = shift;
87100001120ms100001145ms Carp::croak "missing status" unless $self->status();
# spent 145ms making 100001 calls to Plack::Util::Accessor::__ANON__[Plack/Util/Accessor.pm:19], avg 1µs/call
88
89100001125ms100001120ms my $headers = $self->headers;
# spent 120ms making 100001 calls to Plack::Response::headers, avg 1µs/call
9010000124.7ms my @headers;
91
# spent 2.89s (2.32+572ms) within Plack::Response::__ANON__[/usr/local/share/perl/5.18.2/Plack/Response.pm:96] which was called 300003 times, avg 10µs/call: # 300003 times (2.32s+572ms) by HTTP::Headers::Fast::scan at line 296 of HTTP/Headers/Fast.pm, avg 10µs/call
$headers->scan(sub{
92300003175ms my ($k,$v) = @_;
933000031.09s300003193ms $v =~ s/\015\012[\040|\011]+/chr(32)/ge; # replace LWS with a single SP
# spent 193ms making 300003 calls to Plack::Response::CORE:subst, avg 644ns/call
943000031.17s300003379ms $v =~ s/\015|\012//g; # remove CR and LF since the char is invalid here
# spent 379ms making 300003 calls to Plack::Response::CORE:subst, avg 1µs/call
953000031.64s push @headers, $k, $v;
96100001885ms1000017.31s });
# spent 7.31s making 100001 calls to HTTP::Headers::Fast::scan, avg 73µs/call
97
98100001266ms1000011.18s $self->_finalize_cookies(\@headers);
# spent 1.18s making 100001 calls to Plack::Response::_finalize_cookies, avg 12µs/call
99
100 return [
101100001826ms2000021.27s $self->status,
# spent 1.14s making 100001 calls to Plack::Response::_body, avg 11µs/call # spent 135ms making 100001 calls to Plack::Util::Accessor::__ANON__[Plack/Util/Accessor.pm:19], avg 1µs/call
102 \@headers,
103 $self->_body,
104 ];
105}
106
107sub to_app {
108 my $self = shift;
109 return sub { $self->finalize };
110}
111
112
113
# spent 1.14s (1.00+136ms) within Plack::Response::_body which was called 100001 times, avg 11µs/call: # 100001 times (1.00s+136ms) by Plack::Response::finalize at line 101, avg 11µs/call
sub _body {
11410000137.6ms my $self = shift;
115100001162ms100001136ms my $body = $self->body;
# spent 136ms making 100001 calls to Plack::Util::Accessor::__ANON__[Plack/Util/Accessor.pm:19], avg 1µs/call
11610000137.9ms $body = [] unless defined $body;
117100001488ms if (!ref $body or Scalar::Util::blessed($body) && overload::Method($body, q("")) && !$body->can('getline')) {
118 return [ $body ];
119 } else {
120 return $body;
121 }
122}
123
124
# spent 1.18s (831ms+349ms) within Plack::Response::_finalize_cookies which was called 100001 times, avg 12µs/call: # 100001 times (831ms+349ms) by Plack::Response::finalize at line 98, avg 12µs/call
sub _finalize_cookies {
12510000143.0ms my($self, $headers) = @_;
126
127100001712ms100001349ms foreach my $name ( keys %{ $self->cookies } ) {
# spent 349ms making 100001 calls to Plack::Response::cookies, avg 3µs/call
128 my $val = $self->cookies->{$name};
129
130 my $cookie = Cookie::Baker::bake_cookie( $name, $val );
131 push @$headers, 'Set-Cookie' => $cookie;
132 }
133}
134
13512µs1;
136__END__
 
# spent 572ms within Plack::Response::CORE:subst which was called 600006 times, avg 954ns/call: # 300003 times (379ms+0s) by Plack::Response::__ANON__[/usr/local/share/perl/5.18.2/Plack/Response.pm:96] at line 94, avg 1µs/call # 300003 times (193ms+0s) by Plack::Response::__ANON__[/usr/local/share/perl/5.18.2/Plack/Response.pm:96] at line 93, avg 644ns/call
sub Plack::Response::CORE:subst; # opcode