Filename | /usr/share/perl5/URI/_server.pm |
Statements | Executed 53 statements in 1.57ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
2 | 1 | 1 | 699µs | 2.83ms | _host_escape | URI::_server::
2 | 1 | 1 | 54µs | 2.97ms | _uric_escape | URI::_server::
2 | 1 | 1 | 21µs | 21µs | CORE:regcomp (opcode) | URI::_server::
1 | 1 | 1 | 18µs | 134µs | host | URI::_server::
1 | 1 | 1 | 12µs | 26µs | BEGIN@5 | URI::_server::
1 | 1 | 1 | 12µs | 19µs | userinfo | URI::_server::
1 | 1 | 1 | 11µs | 50µs | BEGIN@6 | URI::_server::
6 | 4 | 1 | 10µs | 10µs | CORE:match (opcode) | URI::_server::
1 | 1 | 1 | 9µs | 19µs | _port | URI::_server::
1 | 1 | 1 | 6µs | 26µs | port | URI::_server::
7 | 5 | 1 | 6µs | 6µs | CORE:subst (opcode) | URI::_server::
0 | 0 | 0 | 0s | 0s | as_iri | URI::_server::
0 | 0 | 0 | 0s | 0s | canonical | URI::_server::
0 | 0 | 0 | 0s | 0s | default_port | URI::_server::
0 | 0 | 0 | 0s | 0s | host_port | URI::_server::
0 | 0 | 0 | 0s | 0s | ihost | URI::_server::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package URI::_server; | ||||
2 | 1 | 97µs | require URI::_generic; | ||
3 | 1 | 5µs | @ISA=qw(URI::_generic); | ||
4 | |||||
5 | 2 | 31µs | 2 | 41µs | # spent 26µs (12+14) within URI::_server::BEGIN@5 which was called:
# once (12µs+14µs) by URI::implementor at line 5 # spent 26µs making 1 call to URI::_server::BEGIN@5
# spent 14µs making 1 call to strict::import |
6 | 2 | 1.21ms | 2 | 89µs | # spent 50µs (11+39) within URI::_server::BEGIN@6 which was called:
# once (11µs+39µs) by URI::implementor at line 6 # spent 50µs making 1 call to URI::_server::BEGIN@6
# spent 39µs making 1 call to Exporter::import |
7 | |||||
8 | # spent 2.97ms (54µs+2.91) within URI::_server::_uric_escape which was called 2 times, avg 1.48ms/call:
# 2 times (54µs+2.91ms) by URI::_init at line 81 of URI.pm, avg 1.48ms/call | ||||
9 | 2 | 700ns | my($class, $str) = @_; | ||
10 | 2 | 44µs | 4 | 27µs | if ($str =~ m,^((?:$URI::scheme_re:)?)//([^/?\#]*)(.*)$,os) { # spent 21µs making 2 calls to URI::_server::CORE:regcomp, avg 10µs/call
# spent 6µs making 2 calls to URI::_server::CORE:match, avg 3µs/call |
11 | 2 | 6µs | my($scheme, $host, $rest) = ($1, $2, $3); | ||
12 | 2 | 7µs | 2 | 1µs | my $ui = $host =~ s/(.*@)// ? $1 : ""; # spent 1µs making 2 calls to URI::_server::CORE:subst, avg 500ns/call |
13 | 2 | 8µs | 2 | 3µs | my $port = $host =~ s/(:\d+)\z// ? $1 : ""; # spent 3µs making 2 calls to URI::_server::CORE:subst, avg 1µs/call |
14 | 2 | 5µs | 2 | 2.83ms | if (_host_escape($host)) { # spent 2.83ms making 2 calls to URI::_server::_host_escape, avg 1.41ms/call |
15 | $str = "$scheme//$ui$host$port$rest"; | ||||
16 | } | ||||
17 | } | ||||
18 | 2 | 11µs | 2 | 54µs | return $class->SUPER::_uric_escape($str); # spent 54µs making 2 calls to URI::_uric_escape, avg 27µs/call |
19 | } | ||||
20 | |||||
21 | # spent 2.83ms (699µs+2.13) within URI::_server::_host_escape which was called 2 times, avg 1.41ms/call:
# 2 times (699µs+2.13ms) by URI::_server::_uric_escape at line 14, avg 1.41ms/call | ||||
22 | 2 | 6µs | 2 | 2µs | return unless $_[0] =~ /[^URI::uric]/; # spent 2µs making 2 calls to URI::_server::CORE:match, avg 900ns/call |
23 | 2 | 1µs | eval { | ||
24 | 2 | 82µs | require URI::_idna; | ||
25 | 2 | 5µs | 2 | 118µs | $_[0] = URI::_idna::encode($_[0]); # spent 118µs making 2 calls to URI::_idna::encode, avg 59µs/call |
26 | }; | ||||
27 | 2 | 400ns | return 0 if $@; | ||
28 | 2 | 5µs | return 1; | ||
29 | } | ||||
30 | |||||
31 | sub as_iri { | ||||
32 | my $self = shift; | ||||
33 | my $str = $self->SUPER::as_iri; | ||||
34 | if ($str =~ /\bxn--/) { | ||||
35 | if ($str =~ m,^((?:$URI::scheme_re:)?)//([^/?\#]*)(.*)$,os) { | ||||
36 | my($scheme, $host, $rest) = ($1, $2, $3); | ||||
37 | my $ui = $host =~ s/(.*@)// ? $1 : ""; | ||||
38 | my $port = $host =~ s/(:\d+)\z// ? $1 : ""; | ||||
39 | require URI::_idna; | ||||
40 | $host = URI::_idna::decode($host); | ||||
41 | $str = "$scheme//$ui$host$port$rest"; | ||||
42 | } | ||||
43 | } | ||||
44 | return $str; | ||||
45 | } | ||||
46 | |||||
47 | sub userinfo | ||||
48 | # spent 19µs (12+7) within URI::_server::userinfo which was called:
# once (12µs+7µs) by Search::Elasticsearch::Role::Cxn::HTTP::BUILDARGS at line 40 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm | ||||
49 | 1 | 200ns | my $self = shift; | ||
50 | 1 | 5µs | 1 | 7µs | my $old = $self->authority; # spent 7µs making 1 call to URI::_generic::authority |
51 | |||||
52 | 1 | 200ns | if (@_) { | ||
53 | my $new = $old; | ||||
54 | $new = "" unless defined $new; | ||||
55 | $new =~ s/.*@//; # remove old stuff | ||||
56 | my $ui = shift; | ||||
57 | if (defined $ui) { | ||||
58 | $ui =~ s/@/%40/g; # protect @ | ||||
59 | $new = "$ui\@$new"; | ||||
60 | } | ||||
61 | $self->authority($new); | ||||
62 | } | ||||
63 | 1 | 6µs | 1 | 400ns | return undef if !defined($old) || $old !~ /(.*)@/; # spent 400ns making 1 call to URI::_server::CORE:match |
64 | return $1; | ||||
65 | } | ||||
66 | |||||
67 | sub host | ||||
68 | # spent 134µs (18+116) within URI::_server::host which was called:
# once (18µs+116µs) by Search::Elasticsearch::Role::Cxn::HTTP::BUILDARGS at line 40 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm | ||||
69 | 1 | 300ns | my $self = shift; | ||
70 | 1 | 4µs | 1 | 106µs | my $old = $self->authority; # spent 106µs making 1 call to URI::_generic::authority |
71 | 1 | 200ns | if (@_) { | ||
72 | my $tmp = $old; | ||||
73 | $tmp = "" unless defined $tmp; | ||||
74 | my $ui = ($tmp =~ /(.*@)/) ? $1 : ""; | ||||
75 | my $port = ($tmp =~ /(:\d+)$/) ? $1 : ""; | ||||
76 | my $new = shift; | ||||
77 | $new = "" unless defined $new; | ||||
78 | if (length $new) { | ||||
79 | $new =~ s/[@]/%40/g; # protect @ | ||||
80 | if ($new =~ /^[^:]*:\d*\z/ || $new =~ /]:\d*\z/) { | ||||
81 | $new =~ s/(:\d*)\z// || die "Assert"; | ||||
82 | $port = $1; | ||||
83 | } | ||||
84 | $new = "[$new]" if $new =~ /:/ && $new !~ /^\[/; # IPv6 address | ||||
85 | _host_escape($new); | ||||
86 | } | ||||
87 | $self->authority("$ui$new$port"); | ||||
88 | } | ||||
89 | 1 | 200ns | return undef unless defined $old; | ||
90 | 1 | 3µs | 1 | 500ns | $old =~ s/.*@//; # spent 500ns making 1 call to URI::_server::CORE:subst |
91 | 1 | 4µs | 1 | 2µs | $old =~ s/:\d+$//; # remove the port # spent 2µs making 1 call to URI::_server::CORE:subst |
92 | 1 | 3µs | 1 | 300ns | $old =~ s{^\[(.*)\]$}{$1}; # remove brackets around IPv6 (RFC 3986 3.2.2) # spent 300ns making 1 call to URI::_server::CORE:subst |
93 | 1 | 5µs | 1 | 8µs | return uri_unescape($old); # spent 8µs making 1 call to URI::Escape::uri_unescape |
94 | } | ||||
95 | |||||
96 | sub ihost | ||||
97 | { | ||||
98 | my $self = shift; | ||||
99 | my $old = $self->host(@_); | ||||
100 | if ($old =~ /(^|\.)xn--/) { | ||||
101 | require URI::_idna; | ||||
102 | $old = URI::_idna::decode($old); | ||||
103 | } | ||||
104 | return $old; | ||||
105 | } | ||||
106 | |||||
107 | sub _port | ||||
108 | # spent 19µs (9+10) within URI::_server::_port which was called:
# once (9µs+10µs) by URI::_server::port at line 125 | ||||
109 | 1 | 200ns | my $self = shift; | ||
110 | 1 | 1µs | 1 | 9µs | my $old = $self->authority; # spent 9µs making 1 call to URI::_generic::authority |
111 | 1 | 200ns | if (@_) { | ||
112 | my $new = $old; | ||||
113 | $new =~ s/:\d*$//; | ||||
114 | my $port = shift; | ||||
115 | $new .= ":$port" if defined $port; | ||||
116 | $self->authority($new); | ||||
117 | } | ||||
118 | 1 | 8µs | 1 | 2µs | return $1 if defined($old) && $old =~ /:(\d*)$/; # spent 2µs making 1 call to URI::_server::CORE:match |
119 | return; | ||||
120 | } | ||||
121 | |||||
122 | sub port | ||||
123 | # spent 26µs (6+19) within URI::_server::port which was called:
# once (6µs+19µs) by Search::Elasticsearch::Role::Cxn::HTTP::BUILDARGS at line 40 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm | ||||
124 | 1 | 300ns | my $self = shift; | ||
125 | 1 | 2µs | 1 | 19µs | my $port = $self->_port(@_); # spent 19µs making 1 call to URI::_server::_port |
126 | 1 | 500ns | $port = $self->default_port if !defined($port) || $port eq ""; | ||
127 | 1 | 3µs | $port; | ||
128 | } | ||||
129 | |||||
130 | sub host_port | ||||
131 | { | ||||
132 | my $self = shift; | ||||
133 | my $old = $self->authority; | ||||
134 | $self->host(shift) if @_; | ||||
135 | return undef unless defined $old; | ||||
136 | $old =~ s/.*@//; # zap userinfo | ||||
137 | $old =~ s/:$//; # empty port should be treated the same a no port | ||||
138 | $old .= ":" . $self->port unless $old =~ /:\d+$/; | ||||
139 | $old; | ||||
140 | } | ||||
141 | |||||
142 | |||||
143 | sub default_port { undef } | ||||
144 | |||||
145 | sub canonical | ||||
146 | { | ||||
147 | my $self = shift; | ||||
148 | my $other = $self->SUPER::canonical; | ||||
149 | my $host = $other->host || ""; | ||||
150 | my $port = $other->_port; | ||||
151 | my $uc_host = $host =~ /[A-Z]/; | ||||
152 | my $def_port = defined($port) && ($port eq "" || | ||||
153 | $port == $self->default_port); | ||||
154 | if ($uc_host || $def_port) { | ||||
155 | $other = $other->clone if $other == $self; | ||||
156 | $other->host(lc $host) if $uc_host; | ||||
157 | $other->port(undef) if $def_port; | ||||
158 | } | ||||
159 | $other; | ||||
160 | } | ||||
161 | |||||
162 | 1 | 2µs | 1; | ||
# spent 10µs within URI::_server::CORE:match which was called 6 times, avg 2µs/call:
# 2 times (6µs+0s) by URI::_server::_uric_escape at line 10, avg 3µs/call
# 2 times (2µs+0s) by URI::_server::_host_escape at line 22, avg 900ns/call
# once (2µs+0s) by URI::_server::_port at line 118
# once (400ns+0s) by URI::_server::userinfo at line 63 | |||||
# spent 21µs within URI::_server::CORE:regcomp which was called 2 times, avg 10µs/call:
# 2 times (21µs+0s) by URI::_server::_uric_escape at line 10, avg 10µs/call | |||||
# spent 6µs within URI::_server::CORE:subst which was called 7 times, avg 900ns/call:
# 2 times (3µs+0s) by URI::_server::_uric_escape at line 13, avg 1µs/call
# 2 times (1µs+0s) by URI::_server::_uric_escape at line 12, avg 500ns/call
# once (2µs+0s) by URI::_server::host at line 91
# once (500ns+0s) by URI::_server::host at line 90
# once (300ns+0s) by URI::_server::host at line 92 |