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

Filename/usr/local/share/perl/5.18.2/HTTP/Status.pm
StatementsExecuted 100375 statements in 465ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10000111321ms321msHTTP::Status::::status_messageHTTP::Status::status_message
1871128µs28µsHTTP::Status::::CORE:matchHTTP::Status::CORE:match (opcode)
591120µs20µsHTTP::Status::::CORE:substHTTP::Status::CORE:subst (opcode)
11110µs20µsHTTP::Status::::BEGIN@3HTTP::Status::BEGIN@3
1119µs16µsHTTP::Status::::BEGIN@4HTTP::Status::BEGIN@4
1118µs71µsHTTP::Status::::BEGIN@8HTTP::Status::BEGIN@8
0000s0sHTTP::Status::::is_client_errorHTTP::Status::is_client_error
0000s0sHTTP::Status::::is_errorHTTP::Status::is_error
0000s0sHTTP::Status::::is_infoHTTP::Status::is_info
0000s0sHTTP::Status::::is_redirectHTTP::Status::is_redirect
0000s0sHTTP::Status::::is_server_errorHTTP::Status::is_server_error
0000s0sHTTP::Status::::is_successHTTP::Status::is_success
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package HTTP::Status;
2
3221µs231µs
# spent 20µs (10+10) within HTTP::Status::BEGIN@3 which was called: # once (10µs+10µs) by HTTP::Server::PSGI::BEGIN@10 at line 3
use strict;
# spent 20µs making 1 call to HTTP::Status::BEGIN@3 # spent 10µs making 1 call to strict::import
4226µs224µs
# spent 16µs (9+7) within HTTP::Status::BEGIN@4 which was called: # once (9µs+7µs) by HTTP::Server::PSGI::BEGIN@10 at line 4
use warnings;
# spent 16µs making 1 call to HTTP::Status::BEGIN@4 # spent 7µs making 1 call to warnings::import
5
6111µsrequire 5.002; # because we use prototypes
7
82387µs2134µs
# spent 71µs (8+63) within HTTP::Status::BEGIN@8 which was called: # once (8µs+63µs) by HTTP::Server::PSGI::BEGIN@10 at line 8
use base 'Exporter';
# spent 71µs making 1 call to HTTP::Status::BEGIN@8 # spent 63µs making 1 call to base::import
911µsour @EXPORT = qw(is_info is_success is_redirect is_error status_message);
101300nsour @EXPORT_OK = qw(is_client_error is_server_error);
11
121200nsour $VERSION = "6.11";
13
14# Note also addition of mnemonics to @EXPORT below
15
16# Unmarked codes are from RFC 2616
17# See also: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
18
19129µsmy %StatusCode = (
20 100 => 'Continue',
21 101 => 'Switching Protocols',
22 102 => 'Processing', # RFC 2518 (WebDAV)
23 200 => 'OK',
24 201 => 'Created',
25 202 => 'Accepted',
26 203 => 'Non-Authoritative Information',
27 204 => 'No Content',
28 205 => 'Reset Content',
29 206 => 'Partial Content',
30 207 => 'Multi-Status', # RFC 2518 (WebDAV)
31 208 => 'Already Reported', # RFC 5842
32 300 => 'Multiple Choices',
33 301 => 'Moved Permanently',
34 302 => 'Found',
35 303 => 'See Other',
36 304 => 'Not Modified',
37 305 => 'Use Proxy',
38 307 => 'Temporary Redirect',
39 308 => 'Permanent Redirect', # RFC 7238
40 400 => 'Bad Request',
41 401 => 'Unauthorized',
42 402 => 'Payment Required',
43 403 => 'Forbidden',
44 404 => 'Not Found',
45 405 => 'Method Not Allowed',
46 406 => 'Not Acceptable',
47 407 => 'Proxy Authentication Required',
48 408 => 'Request Timeout',
49 409 => 'Conflict',
50 410 => 'Gone',
51 411 => 'Length Required',
52 412 => 'Precondition Failed',
53 413 => 'Request Entity Too Large',
54 414 => 'Request-URI Too Large',
55 415 => 'Unsupported Media Type',
56 416 => 'Request Range Not Satisfiable',
57 417 => 'Expectation Failed',
58 418 => 'I\'m a teapot', # RFC 2324
59 422 => 'Unprocessable Entity', # RFC 2518 (WebDAV)
60 423 => 'Locked', # RFC 2518 (WebDAV)
61 424 => 'Failed Dependency', # RFC 2518 (WebDAV)
62 425 => 'No code', # WebDAV Advanced Collections
63 426 => 'Upgrade Required', # RFC 2817
64 428 => 'Precondition Required',
65 429 => 'Too Many Requests',
66 431 => 'Request Header Fields Too Large',
67 449 => 'Retry with', # unofficial Microsoft
68 500 => 'Internal Server Error',
69 501 => 'Not Implemented',
70 502 => 'Bad Gateway',
71 503 => 'Service Unavailable',
72 504 => 'Gateway Timeout',
73 505 => 'HTTP Version Not Supported',
74 506 => 'Variant Also Negotiates', # RFC 2295
75 507 => 'Insufficient Storage', # RFC 2518 (WebDAV)
76 509 => 'Bandwidth Limit Exceeded', # unofficial
77 510 => 'Not Extended', # RFC 2774
78 511 => 'Network Authentication Required',
79);
80
811200nsmy $mnemonicCode = '';
8210smy ($code, $message);
8311µswhile (($code, $message) = each %StatusCode) {
84 # create mnemonic subroutines
8559105µs5920µs $message =~ s/I'm/I am/;
# spent 20µs making 59 calls to HTTP::Status::CORE:subst, avg 344ns/call
865912µs $message =~ tr/a-z \-/A-Z__/;
875926µs $mnemonicCode .= "sub HTTP_$message () { $code }\n";
885918µs $mnemonicCode .= "*RC_$message = \\&HTTP_$message;\n"; # legacy
895913µs $mnemonicCode .= "push(\@EXPORT_OK, 'HTTP_$message');\n";
905940µs $mnemonicCode .= "push(\@EXPORT, 'RC_$message');\n";
91}
9211.29mseval $mnemonicCode; # only one eval for speed
# spent 71µs executing statements in string eval
931200nsdie if $@;
94
95# backwards compatibility
961500ns*RC_MOVED_TEMPORARILY = \&RC_FOUND; # 302 was renamed in the standard
971400nspush(@EXPORT, "RC_MOVED_TEMPORARILY");
98
991212µs18728µsour %EXPORT_TAGS = (
# spent 28µs making 187 calls to HTTP::Status::CORE:match, avg 149ns/call
100 constants => [grep /^HTTP_/, @EXPORT_OK],
101 is => [grep /^is_/, @EXPORT, @EXPORT_OK],
102);
103
104
105100001463ms
# spent 321ms within HTTP::Status::status_message which was called 100001 times, avg 3µs/call: # 100001 times (321ms+0s) by HTTP::Server::PSGI::_handle_response at line 207 of HTTP/Server/PSGI.pm, avg 3µs/call
sub status_message ($) { $StatusCode{$_[0]}; }
106
107sub is_info ($) { $_[0] >= 100 && $_[0] < 200; }
108sub is_success ($) { $_[0] >= 200 && $_[0] < 300; }
109sub is_redirect ($) { $_[0] >= 300 && $_[0] < 400; }
110sub is_error ($) { $_[0] >= 400 && $_[0] < 600; }
111sub is_client_error ($) { $_[0] >= 400 && $_[0] < 500; }
112sub is_server_error ($) { $_[0] >= 500 && $_[0] < 600; }
113
114117µs1;
115
116
117__END__
 
# spent 28µs within HTTP::Status::CORE:match which was called 187 times, avg 149ns/call: # 187 times (28µs+0s) by HTTP::Server::PSGI::BEGIN@10 at line 99, avg 149ns/call
sub HTTP::Status::CORE:match; # opcode
# spent 20µs within HTTP::Status::CORE:subst which was called 59 times, avg 344ns/call: # 59 times (20µs+0s) by HTTP::Server::PSGI::BEGIN@10 at line 85, avg 344ns/call
sub HTTP::Status::CORE:subst; # opcode