← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:51 2015

Filename/usr/share/perl5/HTTP/Status.pm
StatementsExecuted 368 statements in 2.03ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1841121µs21µsHTTP::Status::::CORE:matchHTTP::Status::CORE:match (opcode)
581115µs15µsHTTP::Status::::CORE:substHTTP::Status::CORE:subst (opcode)
11111µs21µsHTTP::Status::::BEGIN@3HTTP::Status::BEGIN@3
1117µs63µsHTTP::Status::::BEGIN@6HTTP::Status::BEGIN@6
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
0000s0sHTTP::Status::::status_messageHTTP::Status::status_message
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
3230µs231µs
# spent 21µs (11+10) within HTTP::Status::BEGIN@3 which was called: # once (11µs+10µs) by HTTP::Response::BEGIN@8 at line 3
use strict;
# spent 21µs making 1 call to HTTP::Status::BEGIN@3 # spent 10µs making 1 call to strict::import
4113µsrequire 5.002; # because we use prototypes
5
62397µs2118µs
# spent 63µs (7+55) within HTTP::Status::BEGIN@6 which was called: # once (7µs+55µs) by HTTP::Response::BEGIN@8 at line 6
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION);
# spent 63µs making 1 call to HTTP::Status::BEGIN@6 # spent 55µs making 1 call to vars::import
7
81600nsrequire Exporter;
916µs@ISA = qw(Exporter);
101700ns@EXPORT = qw(is_info is_success is_redirect is_error status_message);
111300ns@EXPORT_OK = qw(is_client_error is_server_error);
121100ns$VERSION = "6.03";
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
19145µ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 400 => 'Bad Request',
40 401 => 'Unauthorized',
41 402 => 'Payment Required',
42 403 => 'Forbidden',
43 404 => 'Not Found',
44 405 => 'Method Not Allowed',
45 406 => 'Not Acceptable',
46 407 => 'Proxy Authentication Required',
47 408 => 'Request Timeout',
48 409 => 'Conflict',
49 410 => 'Gone',
50 411 => 'Length Required',
51 412 => 'Precondition Failed',
52 413 => 'Request Entity Too Large',
53 414 => 'Request-URI Too Large',
54 415 => 'Unsupported Media Type',
55 416 => 'Request Range Not Satisfiable',
56 417 => 'Expectation Failed',
57 418 => 'I\'m a teapot', # RFC 2324
58 422 => 'Unprocessable Entity', # RFC 2518 (WebDAV)
59 423 => 'Locked', # RFC 2518 (WebDAV)
60 424 => 'Failed Dependency', # RFC 2518 (WebDAV)
61 425 => 'No code', # WebDAV Advanced Collections
62 426 => 'Upgrade Required', # RFC 2817
63 428 => 'Precondition Required',
64 429 => 'Too Many Requests',
65 431 => 'Request Header Fields Too Large',
66 449 => 'Retry with', # unofficial Microsoft
67 500 => 'Internal Server Error',
68 501 => 'Not Implemented',
69 502 => 'Bad Gateway',
70 503 => 'Service Unavailable',
71 504 => 'Gateway Timeout',
72 505 => 'HTTP Version Not Supported',
73 506 => 'Variant Also Negotiates', # RFC 2295
74 507 => 'Insufficient Storage', # RFC 2518 (WebDAV)
75 509 => 'Bandwidth Limit Exceeded', # unofficial
76 510 => 'Not Extended', # RFC 2774
77 511 => 'Network Authentication Required',
78);
79
801200nsmy $mnemonicCode = '';
811100nsmy ($code, $message);
8212µswhile (($code, $message) = each %StatusCode) {
83 # create mnemonic subroutines
845867µs5815µs $message =~ s/I'm/I am/;
# spent 15µs making 58 calls to HTTP::Status::CORE:subst, avg 253ns/call
855812µs $message =~ tr/a-z \-/A-Z__/;
865820µs $mnemonicCode .= "sub HTTP_$message () { $code }\n";
875814µs $mnemonicCode .= "*RC_$message = \\&HTTP_$message;\n"; # legacy
885811µs $mnemonicCode .= "push(\@EXPORT_OK, 'HTTP_$message');\n";
895839µs $mnemonicCode .= "push(\@EXPORT, 'RC_$message');\n";
90}
9111.20mseval $mnemonicCode; # only one eval for speed
# spent 55µs executing statements in string eval
921200nsdie if $@;
93
94# backwards compatibility
951600ns*RC_MOVED_TEMPORARILY = \&RC_FOUND; # 302 was renamed in the standard
961400nspush(@EXPORT, "RC_MOVED_TEMPORARILY");
97
981158µs18421µs%EXPORT_TAGS = (
# spent 21µs making 184 calls to HTTP::Status::CORE:match, avg 116ns/call
99 constants => [grep /^HTTP_/, @EXPORT_OK],
100 is => [grep /^is_/, @EXPORT, @EXPORT_OK],
101);
102
103
104sub status_message ($) { $StatusCode{$_[0]}; }
105
106sub is_info ($) { $_[0] >= 100 && $_[0] < 200; }
107sub is_success ($) { $_[0] >= 200 && $_[0] < 300; }
108sub is_redirect ($) { $_[0] >= 300 && $_[0] < 400; }
109sub is_error ($) { $_[0] >= 400 && $_[0] < 600; }
110sub is_client_error ($) { $_[0] >= 400 && $_[0] < 500; }
111sub is_server_error ($) { $_[0] >= 500 && $_[0] < 600; }
112
113116µs1;
114
115
116__END__
 
# spent 21µs within HTTP::Status::CORE:match which was called 184 times, avg 116ns/call: # 184 times (21µs+0s) by HTTP::Response::BEGIN@8 at line 98, avg 116ns/call
sub HTTP::Status::CORE:match; # opcode
# spent 15µs within HTTP::Status::CORE:subst which was called 58 times, avg 253ns/call: # 58 times (15µs+0s) by HTTP::Response::BEGIN@8 at line 84, avg 253ns/call
sub HTTP::Status::CORE:subst; # opcode