← 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:11 2016

Filename/usr/local/share/perl/5.18.2/HTTP/Server/PSGI.pm
StatementsExecuted 10200165 statements in 50.7s
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
3000032110.8s32.0sHTTP::Server::PSGI::::do_timeoutHTTP::Server::PSGI::do_timeout
100001116.01s1011sHTTP::Server::PSGI::::handle_connectionHTTP::Server::PSGI::handle_connection
100001115.51s38.6sHTTP::Server::PSGI::::_handle_responseHTTP::Server::PSGI::_handle_response
200002213.50s26.4sHTTP::Server::PSGI::::write_allHTTP::Server::PSGI::write_all
200002112.22s20.6sHTTP::Server::PSGI::::write_timeoutHTTP::Server::PSGI::write_timeout
200002111.30s9.88sHTTP::Server::PSGI::::__ANON__[:276]HTTP::Server::PSGI::__ANON__[:276]
100001111.28s14.9sHTTP::Server::PSGI::::read_timeoutHTTP::Server::PSGI::read_timeout
200002111.22s1.22sHTTP::Server::PSGI::::CORE:matchHTTP::Server::PSGI::CORE:match (opcode)
200002111.12s2.34sHTTP::Server::PSGI::::_encodeHTTP::Server::PSGI::_encode
10000111901ms903msHTTP::Server::PSGI::::CORE:openHTTP::Server::PSGI::CORE:open (opcode)
10000111726ms11.2sHTTP::Server::PSGI::::__ANON__[:224]HTTP::Server::PSGI::__ANON__[:224]
10000111715ms9.26sHTTP::Server::PSGI::::__ANON__[:270]HTTP::Server::PSGI::__ANON__[:270]
30000311625ms625msHTTP::Server::PSGI::::__ANON__[:205]HTTP::Server::PSGI::__ANON__[:205]
1112.29ms2.63msHTTP::Server::PSGI::::BEGIN@10HTTP::Server::PSGI::BEGIN@10
1111.57ms14.3msHTTP::Server::PSGI::::BEGIN@8HTTP::Server::PSGI::BEGIN@8
1111.02ms1.12msHTTP::Server::PSGI::::BEGIN@9HTTP::Server::PSGI::BEGIN@9
111519µs966µsHTTP::Server::PSGI::::BEGIN@19HTTP::Server::PSGI::BEGIN@19
111229µs297µsHTTP::Server::PSGI::::BEGIN@14HTTP::Server::PSGI::BEGIN@14
111190µs935µsHTTP::Server::PSGI::::BEGIN@7HTTP::Server::PSGI::BEGIN@7
111123µs162µsHTTP::Server::PSGI::::BEGIN@6HTTP::Server::PSGI::BEGIN@6
11124µs333µsHTTP::Server::PSGI::::setup_listenerHTTP::Server::PSGI::setup_listener
11115µs55µsHTTP::Server::PSGI::::BEGIN@11HTTP::Server::PSGI::BEGIN@11
1119µs65µsHTTP::Server::PSGI::::BEGIN@22HTTP::Server::PSGI::BEGIN@22
1119µs18µsHTTP::Server::PSGI::::BEGIN@2HTTP::Server::PSGI::BEGIN@2
1118µs418µsHTTP::Server::PSGI::::BEGIN@16HTTP::Server::PSGI::BEGIN@16
1118µs47µsHTTP::Server::PSGI::::BEGIN@31HTTP::Server::PSGI::BEGIN@31
1118µs1.25msHTTP::Server::PSGI::::BEGIN@15HTTP::Server::PSGI::BEGIN@15
1117µs7µsHTTP::Server::PSGI::::newHTTP::Server::PSGI::new
1117µs32µsHTTP::Server::PSGI::::BEGIN@18HTTP::Server::PSGI::BEGIN@18
1116µs10µsHTTP::Server::PSGI::::BEGIN@3HTTP::Server::PSGI::BEGIN@3
1116µs28µsHTTP::Server::PSGI::::BEGIN@32HTTP::Server::PSGI::BEGIN@32
1115µs5µsHTTP::Server::PSGI::::BEGIN@12HTTP::Server::PSGI::BEGIN@12
1115µs5µsHTTP::Server::PSGI::::BEGIN@13HTTP::Server::PSGI::BEGIN@13
1114µs4µsHTTP::Server::PSGI::::BEGIN@5HTTP::Server::PSGI::BEGIN@5
1112µs2µsHTTP::Server::PSGI::::prepare_socket_classHTTP::Server::PSGI::prepare_socket_class
0000s0sHTTP::Server::PSGI::::__ANON__[:186]HTTP::Server::PSGI::__ANON__[:186]
0000s0sHTTP::Server::PSGI::::__ANON__[:239]HTTP::Server::PSGI::__ANON__[:239]
0000s0sHTTP::Server::PSGI::::__ANON__[:240]HTTP::Server::PSGI::__ANON__[:240]
0000s0sHTTP::Server::PSGI::::__ANON__[:247]HTTP::Server::PSGI::__ANON__[:247]
0000s0sHTTP::Server::PSGI::::__ANON__[:42]HTTP::Server::PSGI::__ANON__[:42]
0000s0sHTTP::Server::PSGI::::accept_loopHTTP::Server::PSGI::accept_loop
0000s0sHTTP::Server::PSGI::::runHTTP::Server::PSGI::run
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package HTTP::Server::PSGI;
2219µs226µs
# spent 18µs (9+9) within HTTP::Server::PSGI::BEGIN@2 which was called: # once (9µs+9µs) by parent::import at line 2
use strict;
# spent 18µs making 1 call to HTTP::Server::PSGI::BEGIN@2 # spent 9µs making 1 call to strict::import
3221µs213µs
# spent 10µs (6+3) within HTTP::Server::PSGI::BEGIN@3 which was called: # once (6µs+3µs) by parent::import at line 3
use warnings;
# spent 10µs making 1 call to HTTP::Server::PSGI::BEGIN@3 # spent 3µs making 1 call to warnings::import
4
5218µs14µs
# spent 4µs within HTTP::Server::PSGI::BEGIN@5 which was called: # once (4µs+0s) by parent::import at line 5
use Carp ();
# spent 4µs making 1 call to HTTP::Server::PSGI::BEGIN@5
6289µs1162µs
# spent 162µs (123+39) within HTTP::Server::PSGI::BEGIN@6 which was called: # once (123µs+39µs) by parent::import at line 6
use Plack;
# spent 162µs making 1 call to HTTP::Server::PSGI::BEGIN@6
7291µs2966µs
# spent 935µs (190+745) within HTTP::Server::PSGI::BEGIN@7 which was called: # once (190µs+745µs) by parent::import at line 7
use Plack::HTTPParser qw( parse_http_request );
# spent 935µs making 1 call to HTTP::Server::PSGI::BEGIN@7 # spent 31µs making 1 call to Exporter::import
82120µs214.8ms
# spent 14.3ms (1.57+12.7) within HTTP::Server::PSGI::BEGIN@8 which was called: # once (1.57ms+12.7ms) by parent::import at line 8
use IO::Socket::INET;
# spent 14.3ms making 1 call to HTTP::Server::PSGI::BEGIN@8 # spent 518µs making 1 call to IO::Socket::import
92149µs21.15ms
# spent 1.12ms (1.02+98µs) within HTTP::Server::PSGI::BEGIN@9 which was called: # once (1.02ms+98µs) by parent::import at line 9
use HTTP::Date;
# spent 1.12ms making 1 call to HTTP::Server::PSGI::BEGIN@9 # spent 29µs making 1 call to Exporter::import
102109µs22.81ms
# spent 2.63ms (2.29+341µs) within HTTP::Server::PSGI::BEGIN@10 which was called: # once (2.29ms+341µs) by parent::import at line 10
use HTTP::Status;
# spent 2.63ms making 1 call to HTTP::Server::PSGI::BEGIN@10 # spent 185µs making 1 call to Exporter::import
11225µs264µs
# spent 55µs (15+41) within HTTP::Server::PSGI::BEGIN@11 which was called: # once (15µs+41µs) by parent::import at line 11
use List::Util qw(max sum);
# spent 55µs making 1 call to HTTP::Server::PSGI::BEGIN@11 # spent 8µs making 1 call to List::Util::import
12228µs15µs
# spent 5µs within HTTP::Server::PSGI::BEGIN@12 which was called: # once (5µs+0s) by parent::import at line 12
use Plack::Util;
# spent 5µs making 1 call to HTTP::Server::PSGI::BEGIN@12
13228µs15µs
# spent 5µs within HTTP::Server::PSGI::BEGIN@13 which was called: # once (5µs+0s) by parent::import at line 13
use Stream::Buffered;
# spent 5µs making 1 call to HTTP::Server::PSGI::BEGIN@13
142109µs1297µs
# spent 297µs (229+68) within HTTP::Server::PSGI::BEGIN@14 which was called: # once (229µs+68µs) by parent::import at line 14
use Plack::Middleware::ContentLength;
# spent 297µs making 1 call to HTTP::Server::PSGI::BEGIN@14
15229µs22.48ms
# spent 1.25ms (8µs+1.24) within HTTP::Server::PSGI::BEGIN@15 which was called: # once (8µs+1.24ms) by parent::import at line 15
use POSIX qw(EINTR);
# spent 1.25ms making 1 call to HTTP::Server::PSGI::BEGIN@15 # spent 1.24ms making 1 call to POSIX::import
16224µs2828µs
# spent 418µs (8+410) within HTTP::Server::PSGI::BEGIN@16 which was called: # once (8µs+410µs) by parent::import at line 16
use Socket qw(IPPROTO_TCP TCP_NODELAY);
# spent 418µs making 1 call to HTTP::Server::PSGI::BEGIN@16 # spent 410µs making 1 call to Exporter::import
17
18222µs256µs
# spent 32µs (7+25) within HTTP::Server::PSGI::BEGIN@18 which was called: # once (7µs+25µs) by parent::import at line 18
use Try::Tiny;
# spent 32µs making 1 call to HTTP::Server::PSGI::BEGIN@18 # spent 25µs making 1 call to Exporter::import
192145µs21.14ms
# spent 966µs (519+447) within HTTP::Server::PSGI::BEGIN@19 which was called: # once (519µs+447µs) by parent::import at line 19
use Time::HiRes qw(time);
# spent 966µs making 1 call to HTTP::Server::PSGI::BEGIN@19 # spent 178µs making 1 call to Time::HiRes::import
20
211200nsmy $alarm_interval;
22
# spent 65µs (9+56) within HTTP::Server::PSGI::BEGIN@22 which was called: # once (9µs+56µs) by parent::import at line 29
BEGIN {
2314µs if ($^O eq 'MSWin32') {
24 $alarm_interval = 1;
25 } else {
2611µs156µs Time::HiRes->import('alarm');
# spent 56µs making 1 call to Time::HiRes::import
271300ns $alarm_interval = 0.1;
28 }
29121µs165µs}
# spent 65µs making 1 call to HTTP::Server::PSGI::BEGIN@22
30
31227µs286µs
# spent 47µs (8+39) within HTTP::Server::PSGI::BEGIN@31 which was called: # once (8µs+39µs) by parent::import at line 31
use constant MAX_REQUEST_SIZE => 131072;
# spent 47µs making 1 call to HTTP::Server::PSGI::BEGIN@31 # spent 39µs making 1 call to constant::import
3221.27ms251µs
# spent 28µs (6+23) within HTTP::Server::PSGI::BEGIN@32 which was called: # once (6µs+23µs) by parent::import at line 32
use constant MSWin32 => $^O eq 'MSWin32';
# spent 28µs making 1 call to HTTP::Server::PSGI::BEGIN@32 # spent 23µs making 1 call to constant::import
33
34
# spent 7µs within HTTP::Server::PSGI::new which was called: # once (7µs+0s) by Plack::Handler::HTTP::Server::PSGI::_server at line 19 of Plack/Handler/HTTP/Server/PSGI.pm
sub new {
3511µs my($class, %args) = @_;
36
37 my $self = bless {
38 host => $args{host} || 0,
39 port => $args{port} || 8080,
40 timeout => $args{timeout} || 300,
41 server_software => $args{server_software} || $class,
42 server_ready => $args{server_ready} || sub {},
4314µs ssl => $args{ssl},
44 ipv6 => $args{ipv6},
45 ssl_key_file => $args{ssl_key_file},
46 ssl_cert_file => $args{ssl_cert_file},
47 }, $class;
48
4914µs $self;
50}
51
52sub run {
531300ns my($self, $app) = @_;
5413µs1333µs $self->setup_listener();
# spent 333µs making 1 call to HTTP::Server::PSGI::setup_listener
5512µs $self->accept_loop($app);
56}
57
58
# spent 2µs within HTTP::Server::PSGI::prepare_socket_class which was called: # once (2µs+0s) by HTTP::Server::PSGI::setup_listener at line 93
sub prepare_socket_class {
591200ns my($self, $args) = @_;
60
611300ns if ($self->{ssl} && $self->{ipv6}) {
62 Carp::croak("SSL and IPv6 are not supported at the same time (yet). Choose one.");
63 }
64
651300ns if ($self->{ssl}) {
66 eval { require IO::Socket::SSL; 1 }
67 or Carp::croak("SSL suport requires IO::Socket::SSL");
68 $args->{SSL_key_file} = $self->{ssl_key_file};
69 $args->{SSL_cert_file} = $self->{ssl_cert_file};
70 return "IO::Socket::SSL";
71 } elsif ($self->{ipv6}) {
72 eval { require IO::Socket::IP; 1 }
73 or Carp::croak("IPv6 support requires IO::Socket::IP");
74 $self->{host} ||= '::';
75 $args->{LocalAddr} ||= '::';
76 return "IO::Socket::IP";
77 }
78
7914µs return "IO::Socket::INET";
80}
81
82
# spent 333µs (24+310) within HTTP::Server::PSGI::setup_listener which was called: # once (24µs+310µs) by HTTP::Server::PSGI::run at line 54
sub setup_listener {
831200ns my $self = shift;
84
8513µs my %args = (
86 Listen => SOMAXCONN,
87 LocalPort => $self->{port},
88 LocalAddr => $self->{host},
89 Proto => 'tcp',
90 ReuseAddr => 1,
91 );
92
9311µs12µs my $class = $self->prepare_socket_class(\%args);
# spent 2µs making 1 call to HTTP::Server::PSGI::prepare_socket_class
9414µs1268µs $self->{listen_sock} ||= $class->new(%args)
# spent 268µs making 1 call to IO::Socket::INET::new
95 or die "failed to listen to port $self->{port}: $!";
96
97112µs140µs $self->{server_ready}->({ %$self, proto => $self->{ssl} ? 'https' : 'http' });
# spent 40µs making 1 call to Plack::Runner::__ANON__[Plack/Runner.pm:213]
98}
99
100sub accept_loop {
1011500ns my($self, $app) = @_;
102
10318µs147µs $app = Plack::Middleware::ContentLength->wrap($app);
# spent 47µs making 1 call to Plack::Middleware::wrap
104
1051200ns while (1) {
106100002663ms local $SIG{PIPE} = 'IGNORE';
1071000022.69s20000219.4s if (my $conn = $self->{listen_sock}->accept) {
# spent 17.4s making 100001 calls to IO::Socket::accept, avg 174µs/call # spent 1.94s making 100001 calls to Hash::MultiValue::DESTROY, avg 19µs/call
108100001462ms1000011.32s $conn->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1)
# spent 1.32s making 100001 calls to IO::Socket::setsockopt, avg 13µs/call
109 or die "setsockopt(TCP_NODELAY) failed:$!";
1101000012.67s2000027.86s my $env = {
# spent 5.70s making 100001 calls to IO::Socket::INET::peerhost, avg 57µs/call # spent 2.16s making 100001 calls to IO::Socket::INET::peerport, avg 22µs/call
111 SERVER_PORT => $self->{port},
112 SERVER_NAME => $self->{host},
113 SCRIPT_NAME => '',
114 REMOTE_ADDR => $conn->peerhost,
115 REMOTE_PORT => $conn->peerport || 0,
116 'psgi.version' => [ 1, 1 ],
117 'psgi.errors' => *STDERR,
118 'psgi.url_scheme' => $self->{ssl} ? 'https' : 'http',
119 'psgi.run_once' => Plack::Util::FALSE,
120 'psgi.multithread' => Plack::Util::FALSE,
121 'psgi.multiprocess' => Plack::Util::FALSE,
122 'psgi.streaming' => Plack::Util::TRUE,
123 'psgi.nonblocking' => Plack::Util::FALSE,
124 'psgix.harakiri' => Plack::Util::TRUE,
125 'psgix.input.buffered' => Plack::Util::TRUE,
126 'psgix.io' => $conn,
127 };
128
129100001303ms1000011011s $self->handle_connection($env, $conn, $app);
# spent 1011s making 100001 calls to HTTP::Server::PSGI::handle_connection, avg 10.1ms/call
130100001499ms1000015.14s $conn->close;
# spent 5.14s making 100001 calls to IO::Socket::close, avg 51µs/call
1311000013.32s last if $env->{'psgix.harakiri.commit'};
132 }
133 }
134}
135
136
# spent 1011s (6.01+1005) within HTTP::Server::PSGI::handle_connection which was called 100001 times, avg 10.1ms/call: # 100001 times (6.01s+1005s) by HTTP::Server::PSGI::accept_loop at line 129, avg 10.1ms/call
sub handle_connection {
13710000175.8ms my($self, $env, $conn, $app) = @_;
138
13910000173.8ms my $buf = '';
140100001312ms my $res = [ 400, [ 'Content-Type' => 'text/plain' ], [ 'Bad Request' ] ];
141
14210000137.4ms while (1) {
143100001690ms10000114.9s my $rlen = $self->read_timeout(
# spent 14.9s making 100001 calls to HTTP::Server::PSGI::read_timeout, avg 149µs/call
144 $conn, \$buf, MAX_REQUEST_SIZE - length($buf), length($buf),
145 $self->{timeout},
146 ) or return;
1471000012.18s1000011.57s my $reqlen = parse_http_request($buf, $env);
# spent 1.57s making 100001 calls to HTTP::Parser::XS::parse_http_request, avg 16µs/call
14810000196.2ms if ($reqlen >= 0) {
149100001122ms $buf = substr $buf, $reqlen;
150100001170ms if (my $cl = $env->{CONTENT_LENGTH}) {
151 my $buffer = Stream::Buffered->new($cl);
152 while ($cl > 0) {
153 my $chunk;
154 if (length $buf) {
155 $chunk = $buf;
156 $buf = '';
157 } else {
158 $self->read_timeout($conn, \$chunk, $cl, 0, $self->{timeout})
159 or return;
160 }
161 $buffer->print($chunk);
162 $cl -= length $chunk;
163 }
164 $env->{'psgi.input'} = $buffer->rewind;
165 } else {
1661000031.87s100002903ms open my $input, "<", \$buf;
# spent 903ms making 100001 calls to HTTP::Server::PSGI::CORE:open, avg 9µs/call # spent 572µs making 1 call to PerlIO::import
167100001250ms $env->{'psgi.input'} = $input;
168 }
169
170100001856ms100001950s $res = Plack::Util::run_app $app, $env;
# spent 950s making 100001 calls to Plack::Util::run_app, avg 9.50ms/call
171100001231ms last;
172 }
173 if ($reqlen == -2) {
174 # request is incomplete, do nothing
175 } elsif ($reqlen == -1) {
176 # error, close conn
177 last;
178 }
179 }
180
181100001454ms10000138.6s if (ref $res eq 'ARRAY') {
# spent 38.6s making 100001 calls to HTTP::Server::PSGI::_handle_response, avg 386µs/call
182 $self->_handle_response($res, $conn);
183 } elsif (ref $res eq 'CODE') {
184 $res->(sub {
185 $self->_handle_response($_[0], $conn);
186 });
187 } else {
188 die "Bad response $res";
189 }
190
191100001808ms return;
192}
193
194
# spent 38.6s (5.51+33.1) within HTTP::Server::PSGI::_handle_response which was called 100001 times, avg 386µs/call: # 100001 times (5.51s+33.1s) by HTTP::Server::PSGI::handle_connection at line 181, avg 386µs/call
sub _handle_response {
19510000160.5ms my($self, $res, $conn) = @_;
196
197 my @lines = (
198100001777ms1000011.14s "Date: @{[HTTP::Date::time2str()]}\015\012",
# spent 1.14s making 100001 calls to HTTP::Date::time2str, avg 11µs/call
199 "Server: $self->{server_software}\015\012",
200 );
201
202
# spent 625ms within HTTP::Server::PSGI::__ANON__[/usr/local/share/perl/5.18.2/HTTP/Server/PSGI.pm:205] which was called 300003 times, avg 2µs/call: # 300003 times (625ms+0s) by Plack::Util::header_iter at line 169 of Plack/Util.pm, avg 2µs/call
Plack::Util::header_iter($res->[1], sub {
203300003152ms my ($k, $v) = @_;
2043000031.75s push @lines, "$k: $v\015\012";
205100001689ms1000012.98s });
# spent 2.98s making 100001 calls to Plack::Util::header_iter, avg 30µs/call
206
207100001571ms100001321ms unshift @lines, "HTTP/1.0 $res->[0] @{[ HTTP::Status::status_message($res->[0]) ]}\015\012";
# spent 321ms making 100001 calls to HTTP::Status::status_message, avg 3µs/call
20810000172.3ms push @lines, "\015\012";
209
210100001384ms10000116.0s $self->write_all($conn, join('', @lines), $self->{timeout})
# spent 16.0s making 100001 calls to HTTP::Server::PSGI::write_all, avg 160µs/call
211 or return;
212
213100001724ms if (defined $res->[2]) {
21410000132.2ms my $err;
21510000124.3ms my $done;
216 {
217200002104ms local $@;
218100001116ms eval {
219 Plack::Util::foreach(
220 $res->[2],
221
# spent 11.2s (726ms+10.5) within HTTP::Server::PSGI::__ANON__[/usr/local/share/perl/5.18.2/HTTP/Server/PSGI.pm:224] which was called 100001 times, avg 112µs/call: # 100001 times (726ms+10.5s) by Plack::Util::foreach at line 94 of Plack/Util.pm, avg 112µs/call
sub {
222100001944ms10000110.5s $self->write_all($conn, $_[0], $self->{timeout})
# spent 10.5s making 100001 calls to HTTP::Server::PSGI::write_all, avg 105µs/call
223 or die "failed to send all data\n";
224 },
225100001918ms10000112.7s );
# spent 12.7s making 100001 calls to Plack::Util::foreach, avg 127µs/call
22610000170.0ms $done = 1;
227 };
22810000175.6ms $err = $@;
229 };
23010000151.1ms unless ($done) {
231 if ($err =~ /^failed to send all data\n/) {
232 return;
233 } else {
234 die $err;
235 }
236 }
237 } else {
238 return Plack::Util::inline_object
239 write => sub { $self->write_all($conn, $_[0], $self->{timeout}) },
240 close => sub { };
241 }
242}
243
244# returns 1 if socket is ready, undef on timeout
245
# spent 32.0s (10.8+21.2) within HTTP::Server::PSGI::do_timeout which was called 300003 times, avg 107µs/call: # 200002 times (7.13s+11.3s) by HTTP::Server::PSGI::write_timeout at line 276, avg 92µs/call # 100001 times (3.64s+9.96s) by HTTP::Server::PSGI::read_timeout at line 270, avg 136µs/call
sub do_timeout {
246300003145ms my ($self, $cb, $timeout) = @_;
2473000032.38s local $SIG{ALRM} = sub {};
2483000032.04s300003544ms my $wait_until = time + $timeout;
# spent 544ms making 300003 calls to Time::HiRes::time, avg 2µs/call
2493000032.05s300003924ms alarm($timeout);
# spent 924ms making 300003 calls to Time::HiRes::alarm, avg 3µs/call
25030000354.1ms my $ret;
25130000358.8ms while (1) {
252300003568ms30000319.1s if ($ret = $cb->()) {
# spent 9.88s making 200002 calls to HTTP::Server::PSGI::__ANON__[HTTP/Server/PSGI.pm:276], avg 49µs/call # spent 9.26s making 100001 calls to HTTP::Server::PSGI::__ANON__[HTTP/Server/PSGI.pm:270], avg 93µs/call
253300003240ms last;
254 } elsif (! (! defined($ret) && $! == EINTR)) {
255 undef $ret;
256 last;
257 }
258 # got EINTR
259 my $left = $wait_until - time;
260 last if $left <= 0;
261 alarm($left + $alarm_interval);
262 }
2633000031.79s300003600ms alarm(0);
# spent 600ms making 300003 calls to Time::HiRes::alarm, avg 2µs/call
2643000033.02s $ret;
265}
266
267# returns (positive) number of bytes read, or undef if the socket is to be closed
268
# spent 14.9s (1.28+13.6) within HTTP::Server::PSGI::read_timeout which was called 100001 times, avg 149µs/call: # 100001 times (1.28s+13.6s) by HTTP::Server::PSGI::handle_connection at line 143, avg 149µs/call
sub read_timeout {
269100001101ms my ($self, $sock, $buf, $len, $off, $timeout) = @_;
2702000022.14s20000222.2s
# spent 9.26s (715ms+8.55) within HTTP::Server::PSGI::__ANON__[/usr/local/share/perl/5.18.2/HTTP/Server/PSGI.pm:270] which was called 100001 times, avg 93µs/call: # 100001 times (715ms+8.55s) by HTTP::Server::PSGI::do_timeout at line 252, avg 93µs/call
$self->do_timeout(sub { $sock->sysread($$buf, $len, $off) }, $timeout);
# spent 13.6s making 100001 calls to HTTP::Server::PSGI::do_timeout, avg 136µs/call # spent 8.55s making 100001 calls to IO::Handle::sysread, avg 85µs/call
271}
272
273# returns (positive) number of bytes written, or undef if the socket is to be closed
274
# spent 20.6s (2.22+18.4) within HTTP::Server::PSGI::write_timeout which was called 200002 times, avg 103µs/call: # 200002 times (2.22s+18.4s) by HTTP::Server::PSGI::write_all at line 286, avg 103µs/call
sub write_timeout {
275200002395ms my ($self, $sock, $buf, $len, $off, $timeout) = @_;
2764000043.56s40000427.0s
# spent 9.88s (1.30+8.58) within HTTP::Server::PSGI::__ANON__[/usr/local/share/perl/5.18.2/HTTP/Server/PSGI.pm:276] which was called 200002 times, avg 49µs/call: # 200002 times (1.30s+8.58s) by HTTP::Server::PSGI::do_timeout at line 252, avg 49µs/call
$self->do_timeout(sub { $sock->syswrite($buf, $len, $off) }, $timeout);
# spent 18.4s making 200002 calls to HTTP::Server::PSGI::do_timeout, avg 92µs/call # spent 8.58s making 200002 calls to IO::Handle::syswrite, avg 43µs/call
277}
278
279# writes all data in buf and returns number of bytes written or undef if failed
280
# spent 26.4s (3.50+22.9) within HTTP::Server::PSGI::write_all which was called 200002 times, avg 132µs/call: # 100001 times (1.95s+14.0s) by HTTP::Server::PSGI::_handle_response at line 210, avg 160µs/call # 100001 times (1.55s+8.94s) by HTTP::Server::PSGI::__ANON__[/usr/local/share/perl/5.18.2/HTTP/Server/PSGI.pm:224] at line 222, avg 105µs/call
sub write_all {
281200002170ms my ($self, $sock, $buf, $timeout) = @_;
28220000272.7ms return 0 unless defined $buf;
283200002274ms2000022.34s _encode($buf);
# spent 2.34s making 200002 calls to HTTP::Server::PSGI::_encode, avg 12µs/call
28420000270.0ms my $off = 0;
285200002481ms while (my $len = length($buf) - $off) {
286200002743ms20000220.6s my $ret = $self->write_timeout($sock, $buf, $len, $off, $timeout)
# spent 20.6s making 200002 calls to HTTP::Server::PSGI::write_timeout, avg 103µs/call
287 or return;
288200002133ms $off += $ret;
289 }
2902000021.12s return length $buf;
291}
292
293# syswrite() will crash when given wide characters
294
# spent 2.34s (1.12+1.22) within HTTP::Server::PSGI::_encode which was called 200002 times, avg 12µs/call: # 200002 times (1.12s+1.22s) by HTTP::Server::PSGI::write_all at line 283, avg 12µs/call
sub _encode {
2952000022.77s2000021.22s if ($_[0] =~ /[^\x00-\xff]/) {
# spent 1.22s making 200002 calls to HTTP::Server::PSGI::CORE:match, avg 6µs/call
296 Carp::carp("Wide character outside byte range in response. Encoding data as UTF-8");
297 utf8::encode($_[0]);
298 }
299}
300
30113µs1;
302
303__END__
 
# spent 1.22s within HTTP::Server::PSGI::CORE:match which was called 200002 times, avg 6µs/call: # 200002 times (1.22s+0s) by HTTP::Server::PSGI::_encode at line 295, avg 6µs/call
sub HTTP::Server::PSGI::CORE:match; # opcode
# spent 903ms (901+1.09) within HTTP::Server::PSGI::CORE:open which was called 100001 times, avg 9µs/call: # 100001 times (901ms+1.09ms) by HTTP::Server::PSGI::handle_connection at line 166, avg 9µs/call
sub HTTP::Server::PSGI::CORE:open; # opcode