| Filename | /usr/local/share/perl/5.18.2/HTTP/Status.pm |
| Statements | Executed 100375 statements in 465ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 100001 | 1 | 1 | 321ms | 321ms | HTTP::Status::status_message |
| 187 | 1 | 1 | 28µs | 28µs | HTTP::Status::CORE:match (opcode) |
| 59 | 1 | 1 | 20µs | 20µs | HTTP::Status::CORE:subst (opcode) |
| 1 | 1 | 1 | 10µs | 20µs | HTTP::Status::BEGIN@3 |
| 1 | 1 | 1 | 9µs | 16µs | HTTP::Status::BEGIN@4 |
| 1 | 1 | 1 | 8µs | 71µs | HTTP::Status::BEGIN@8 |
| 0 | 0 | 0 | 0s | 0s | HTTP::Status::is_client_error |
| 0 | 0 | 0 | 0s | 0s | HTTP::Status::is_error |
| 0 | 0 | 0 | 0s | 0s | HTTP::Status::is_info |
| 0 | 0 | 0 | 0s | 0s | HTTP::Status::is_redirect |
| 0 | 0 | 0 | 0s | 0s | HTTP::Status::is_server_error |
| 0 | 0 | 0 | 0s | 0s | HTTP::Status::is_success |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package HTTP::Status; | ||||
| 2 | |||||
| 3 | 2 | 21µs | 2 | 31µ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 # spent 20µs making 1 call to HTTP::Status::BEGIN@3
# spent 10µs making 1 call to strict::import |
| 4 | 2 | 26µs | 2 | 24µ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 # spent 16µs making 1 call to HTTP::Status::BEGIN@4
# spent 7µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 1 | 11µs | require 5.002; # because we use prototypes | ||
| 7 | |||||
| 8 | 2 | 387µs | 2 | 134µ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 # spent 71µs making 1 call to HTTP::Status::BEGIN@8
# spent 63µs making 1 call to base::import |
| 9 | 1 | 1µs | our @EXPORT = qw(is_info is_success is_redirect is_error status_message); | ||
| 10 | 1 | 300ns | our @EXPORT_OK = qw(is_client_error is_server_error); | ||
| 11 | |||||
| 12 | 1 | 200ns | our $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 | |||||
| 19 | 1 | 29µs | my %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 | |||||
| 81 | 1 | 200ns | my $mnemonicCode = ''; | ||
| 82 | 1 | 0s | my ($code, $message); | ||
| 83 | 1 | 1µs | while (($code, $message) = each %StatusCode) { | ||
| 84 | # create mnemonic subroutines | ||||
| 85 | 59 | 105µs | 59 | 20µs | $message =~ s/I'm/I am/; # spent 20µs making 59 calls to HTTP::Status::CORE:subst, avg 344ns/call |
| 86 | 59 | 12µs | $message =~ tr/a-z \-/A-Z__/; | ||
| 87 | 59 | 26µs | $mnemonicCode .= "sub HTTP_$message () { $code }\n"; | ||
| 88 | 59 | 18µs | $mnemonicCode .= "*RC_$message = \\&HTTP_$message;\n"; # legacy | ||
| 89 | 59 | 13µs | $mnemonicCode .= "push(\@EXPORT_OK, 'HTTP_$message');\n"; | ||
| 90 | 59 | 40µs | $mnemonicCode .= "push(\@EXPORT, 'RC_$message');\n"; | ||
| 91 | } | ||||
| 92 | 1 | 1.29ms | eval $mnemonicCode; # only one eval for speed # spent 71µs executing statements in string eval | ||
| 93 | 1 | 200ns | die if $@; | ||
| 94 | |||||
| 95 | # backwards compatibility | ||||
| 96 | 1 | 500ns | *RC_MOVED_TEMPORARILY = \&RC_FOUND; # 302 was renamed in the standard | ||
| 97 | 1 | 400ns | push(@EXPORT, "RC_MOVED_TEMPORARILY"); | ||
| 98 | |||||
| 99 | 1 | 212µs | 187 | 28µs | our %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 | |||||
| 105 | 100001 | 463ms | # 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 | ||
| 106 | |||||
| 107 | sub is_info ($) { $_[0] >= 100 && $_[0] < 200; } | ||||
| 108 | sub is_success ($) { $_[0] >= 200 && $_[0] < 300; } | ||||
| 109 | sub is_redirect ($) { $_[0] >= 300 && $_[0] < 400; } | ||||
| 110 | sub is_error ($) { $_[0] >= 400 && $_[0] < 600; } | ||||
| 111 | sub is_client_error ($) { $_[0] >= 400 && $_[0] < 500; } | ||||
| 112 | sub is_server_error ($) { $_[0] >= 500 && $_[0] < 600; } | ||||
| 113 | |||||
| 114 | 1 | 17µs | 1; | ||
| 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 | |||||
# 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 |