| File | /usr/local/lib/perl5/site_perl/5.10.1/URI/_server.pm |
| Statements Executed | 2357 |
| Statement Execution Time | 6.74ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 123 | 3 | 3 | 1.85ms | 4.26ms | URI::_server::host |
| 42 | 1 | 1 | 1.12ms | 6.38ms | URI::_server::_uric_escape |
| 41 | 1 | 1 | 1.02ms | 5.24ms | URI::_server::canonical |
| 42 | 1 | 1 | 860µs | 4.76ms | URI::_server::_host_escape |
| 82 | 2 | 1 | 819µs | 1.49ms | URI::_server::_port |
| 41 | 1 | 1 | 404µs | 1.07ms | URI::_server::port |
| 207 | 4 | 2 | 248µs | 248µs | URI::_server::CORE:match (opcode) |
| 453 | 5 | 2 | 221µs | 221µs | URI::_server::CORE:subst (opcode) |
| 1 | 1 | 1 | 15µs | 17µs | URI::_server::BEGIN@5 |
| 1 | 1 | 2 | 14µs | 14µs | URI::_server::CORE:regcomp (opcode) |
| 1 | 1 | 1 | 13µs | 53µs | URI::_server::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | URI::_server::as_iri |
| 0 | 0 | 0 | 0s | 0s | URI::_server::default_port |
| 0 | 0 | 0 | 0s | 0s | URI::_server::host_port |
| 0 | 0 | 0 | 0s | 0s | URI::_server::ihost |
| 0 | 0 | 0 | 0s | 0s | URI::_server::userinfo |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package URI::_server; | ||||
| 2 | 1 | 115µs | require URI::_generic; | ||
| 3 | 1 | 6µs | @ISA=qw(URI::_generic); | ||
| 4 | |||||
| 5 | 3 | 22µs | 2 | 20µs | # spent 17µs (15+3) within URI::_server::BEGIN@5 which was called
# once (15µs+3µs) by URI::implementor at line 5 # spent 17µs making 1 call to URI::_server::BEGIN@5
# spent 3µs making 1 call to strict::import |
| 6 | 3 | 866µs | 2 | 93µs | # spent 53µs (13+40) within URI::_server::BEGIN@6 which was called
# once (13µs+40µs) by URI::implementor at line 6 # spent 53µs making 1 call to URI::_server::BEGIN@6
# spent 40µs making 1 call to Exporter::import |
| 7 | |||||
| 8 | # spent 6.38ms (1.12+5.26) within URI::_server::_uric_escape which was called 42 times, avg 152µs/call:
# 42 times (1.12ms+5.26ms) by URI::_init at line 81 of URI.pm, avg 152µs/call | ||||
| 9 | 42 | 61µs | my($class, $str) = @_; | ||
| 10 | 42 | 296µs | 43 | 141µs | if ($str =~ m,^((?:$URI::scheme_re:)?)//([^/?\#]*)(.*)$,os) { # spent 127µs making 42 calls to URI::_server::CORE:match, avg 3µs/call
# spent 14µs making 1 call to URI::_server::CORE:regcomp |
| 11 | 42 | 113µs | my($scheme, $host, $rest) = ($1, $2, $3); | ||
| 12 | 42 | 165µs | 42 | 23µs | my $ui = $host =~ s/(.*@)// ? $1 : ""; # spent 23µs making 42 calls to URI::_server::CORE:subst, avg 552ns/call |
| 13 | 42 | 116µs | 42 | 18µs | my $port = $host =~ s/(:\d+)\z// ? $1 : ""; # spent 18µs making 42 calls to URI::_server::CORE:subst, avg 424ns/call |
| 14 | 42 | 149µs | 42 | 4.76ms | if (_host_escape($host)) { # spent 4.76ms making 42 calls to URI::_server::_host_escape, avg 113µs/call |
| 15 | $str = "$scheme//$ui$host$port$rest"; | ||||
| 16 | } | ||||
| 17 | } | ||||
| 18 | 42 | 330µs | 42 | 314µs | return $class->SUPER::_uric_escape($str); # spent 314µs making 42 calls to URI::_uric_escape, avg 7µs/call |
| 19 | } | ||||
| 20 | |||||
| 21 | # spent 4.76ms (860µs+3.90) within URI::_server::_host_escape which was called 42 times, avg 113µs/call:
# 42 times (860µs+3.90ms) by URI::_server::_uric_escape at line 14, avg 113µs/call | ||||
| 22 | 42 | 129µs | 42 | 37µs | return unless $_[0] =~ /[^URI::uric]/; # spent 37µs making 42 calls to URI::_server::CORE:match, avg 874ns/call |
| 23 | 42 | 143µs | require URI::_idna; | ||
| 24 | 42 | 141µs | 42 | 2.52ms | $_[0] = URI::_idna::encode($_[0]); # spent 2.52ms making 42 calls to URI::_idna::encode, avg 60µs/call |
| 25 | 42 | 99µs | return 1; | ||
| 26 | } | ||||
| 27 | |||||
| 28 | sub as_iri { | ||||
| 29 | my $self = shift; | ||||
| 30 | my $str = $self->SUPER::as_iri; | ||||
| 31 | if ($str =~ /\bxn--/) { | ||||
| 32 | if ($str =~ m,^((?:$URI::scheme_re:)?)//([^/?\#]*)(.*)$,os) { | ||||
| 33 | my($scheme, $host, $rest) = ($1, $2, $3); | ||||
| 34 | my $ui = $host =~ s/(.*@)// ? $1 : ""; | ||||
| 35 | my $port = $host =~ s/(:\d+)\z// ? $1 : ""; | ||||
| 36 | require URI::_idna; | ||||
| 37 | $host = URI::_idna::encode($host); | ||||
| 38 | $str = "$scheme//$ui$host$port$rest"; | ||||
| 39 | } | ||||
| 40 | } | ||||
| 41 | return $str; | ||||
| 42 | } | ||||
| 43 | |||||
| 44 | sub userinfo | ||||
| 45 | { | ||||
| 46 | my $self = shift; | ||||
| 47 | my $old = $self->authority; | ||||
| 48 | |||||
| 49 | if (@_) { | ||||
| 50 | my $new = $old; | ||||
| 51 | $new = "" unless defined $new; | ||||
| 52 | $new =~ s/.*@//; # remove old stuff | ||||
| 53 | my $ui = shift; | ||||
| 54 | if (defined $ui) { | ||||
| 55 | $ui =~ s/@/%40/g; # protect @ | ||||
| 56 | $new = "$ui\@$new"; | ||||
| 57 | } | ||||
| 58 | $self->authority($new); | ||||
| 59 | } | ||||
| 60 | return undef if !defined($old) || $old !~ /(.*)@/; | ||||
| 61 | return $1; | ||||
| 62 | } | ||||
| 63 | |||||
| 64 | sub host | ||||
| 65 | # spent 4.26ms (1.85+2.41) within URI::_server::host which was called 123 times, avg 35µs/call:
# 41 times (865µs+1.10ms) by URI::_server::canonical at line 146, avg 48µs/call
# 41 times (553µs+755µs) by SimpleDB::Client::construct_request at line 177 of SimpleDB/Client.pm, avg 32µs/call
# 41 times (430µs+551µs) by LWP::Protocol::http::request at line 148 of LWP/Protocol/http.pm, avg 24µs/call | ||||
| 66 | 123 | 46µs | my $self = shift; | ||
| 67 | 123 | 340µs | 123 | 1.43ms | my $old = $self->authority; # spent 1.43ms making 123 calls to URI::_generic::authority, avg 12µs/call |
| 68 | 123 | 43µs | if (@_) { | ||
| 69 | my $tmp = $old; | ||||
| 70 | $tmp = "" unless defined $tmp; | ||||
| 71 | my $ui = ($tmp =~ /(.*@)/) ? $1 : ""; | ||||
| 72 | my $port = ($tmp =~ /(:\d+)$/) ? $1 : ""; | ||||
| 73 | my $new = shift; | ||||
| 74 | $new = "" unless defined $new; | ||||
| 75 | if (length $new) { | ||||
| 76 | $new =~ s/[@]/%40/g; # protect @ | ||||
| 77 | if ($new =~ /^[^:]*:\d*\z/ || $new =~ /]:\d*\z/) { | ||||
| 78 | $new =~ s/(:\d*)\z// || die "Assert"; | ||||
| 79 | $port = $1; | ||||
| 80 | } | ||||
| 81 | $new = "[$new]" if $new =~ /:/ && $new !~ /^\[/; # IPv6 address | ||||
| 82 | _host_escape($new); | ||||
| 83 | } | ||||
| 84 | $self->authority("$ui$new$port"); | ||||
| 85 | } | ||||
| 86 | 123 | 34µs | return undef unless defined $old; | ||
| 87 | 123 | 389µs | 123 | 86µs | $old =~ s/.*@//; # spent 86µs making 123 calls to URI::_server::CORE:subst, avg 702ns/call |
| 88 | 123 | 240µs | 123 | 48µs | $old =~ s/:\d+$//; # remove the port # spent 48µs making 123 calls to URI::_server::CORE:subst, avg 393ns/call |
| 89 | 123 | 243µs | 123 | 46µs | $old =~ s{^\[(.*)\]$}{$1}; # remove brackets around IPv6 (RFC 3986 3.2.2) # spent 46µs making 123 calls to URI::_server::CORE:subst, avg 370ns/call |
| 90 | 123 | 568µs | 123 | 796µs | return uri_unescape($old); # spent 796µs making 123 calls to URI::Escape::uri_unescape, avg 6µs/call |
| 91 | } | ||||
| 92 | |||||
| 93 | sub ihost | ||||
| 94 | { | ||||
| 95 | my $self = shift; | ||||
| 96 | my $old = $self->host(@_); | ||||
| 97 | if ($old =~ /(^|\.)xn--/) { | ||||
| 98 | require URI::_idna; | ||||
| 99 | $old = URI::_idna::decode($old); | ||||
| 100 | } | ||||
| 101 | return $old; | ||||
| 102 | } | ||||
| 103 | |||||
| 104 | sub _port | ||||
| 105 | { | ||||
| 106 | 82 | 41µs | my $self = shift; | ||
| 107 | 82 | 153µs | 82 | 615µs | my $old = $self->authority; # spent 615µs making 82 calls to URI::_generic::authority, avg 8µs/call |
| 108 | 82 | 37µs | if (@_) { | ||
| 109 | my $new = $old; | ||||
| 110 | $new =~ s/:\d*$//; | ||||
| 111 | my $port = shift; | ||||
| 112 | $new .= ":$port" if defined $port; | ||||
| 113 | $self->authority($new); | ||||
| 114 | } | ||||
| 115 | 82 | 292µs | 82 | 51µs | return $1 if defined($old) && $old =~ /:(\d*)$/; # spent 51µs making 82 calls to URI::_server::CORE:match, avg 627ns/call |
| 116 | 82 | 227µs | return; | ||
| 117 | } | ||||
| 118 | |||||
| 119 | sub port | ||||
| 120 | # spent 1.07ms (404µs+666µs) within URI::_server::port which was called 41 times, avg 26µs/call:
# 41 times (404µs+666µs) by LWP::Protocol::http::request at line 149 of LWP/Protocol/http.pm, avg 26µs/call | ||||
| 121 | 41 | 19µs | my $self = shift; | ||
| 122 | 41 | 102µs | 41 | 595µs | my $port = $self->_port(@_); # spent 595µs making 41 calls to URI::_server::_port, avg 15µs/call |
| 123 | 41 | 105µs | 41 | 70µs | $port = $self->default_port if !defined($port) || $port eq ""; # spent 70µs making 41 calls to URI::http::default_port, avg 2µs/call |
| 124 | 41 | 97µs | $port; | ||
| 125 | } | ||||
| 126 | |||||
| 127 | sub host_port | ||||
| 128 | { | ||||
| 129 | my $self = shift; | ||||
| 130 | my $old = $self->authority; | ||||
| 131 | $self->host(shift) if @_; | ||||
| 132 | return undef unless defined $old; | ||||
| 133 | $old =~ s/.*@//; # zap userinfo | ||||
| 134 | $old =~ s/:$//; # empty port should be treated the same a no port | ||||
| 135 | $old .= ":" . $self->port unless $old =~ /:\d+$/; | ||||
| 136 | $old; | ||||
| 137 | } | ||||
| 138 | |||||
| 139 | |||||
| 140 | sub default_port { undef } | ||||
| 141 | |||||
| 142 | sub canonical | ||||
| 143 | # spent 5.24ms (1.02+4.21) within URI::_server::canonical which was called 41 times, avg 128µs/call:
# 41 times (1.02ms+4.21ms) by URI::http::canonical at line 13 of URI/http.pm, avg 128µs/call | ||||
| 144 | 41 | 22µs | my $self = shift; | ||
| 145 | 41 | 301µs | 41 | 1.32ms | my $other = $self->SUPER::canonical; # spent 1.32ms making 41 calls to URI::canonical, avg 32µs/call |
| 146 | 41 | 163µs | 41 | 1.97ms | my $host = $other->host || ""; # spent 1.97ms making 41 calls to URI::_server::host, avg 48µs/call |
| 147 | 41 | 149µs | 41 | 890µs | my $port = $other->_port; # spent 890µs making 41 calls to URI::_server::_port, avg 22µs/call |
| 148 | 41 | 147µs | 41 | 33µs | my $uc_host = $host =~ /[A-Z]/; # spent 33µs making 41 calls to URI::_server::CORE:match, avg 815ns/call |
| 149 | 41 | 31µs | my $def_port = defined($port) && ($port eq "" || | ||
| 150 | $port == $self->default_port); | ||||
| 151 | 41 | 18µs | if ($uc_host || $def_port) { | ||
| 152 | $other = $other->clone if $other == $self; | ||||
| 153 | $other->host(lc $host) if $uc_host; | ||||
| 154 | $other->port(undef) if $def_port; | ||||
| 155 | } | ||||
| 156 | 41 | 177µs | $other; | ||
| 157 | } | ||||
| 158 | |||||
| 159 | 1 | 3µs | 1; | ||
# spent 248µs within URI::_server::CORE:match which was called 207 times, avg 1µs/call:
# 82 times (51µs+0s) by URI::_server::_port at line 115 of URI/_server.pm, avg 627ns/call
# 42 times (127µs+0s) by URI::_server::_uric_escape at line 10 of URI/_server.pm, avg 3µs/call
# 42 times (37µs+0s) by URI::_server::_host_escape at line 22 of URI/_server.pm, avg 874ns/call
# 41 times (33µs+0s) by URI::_server::canonical at line 148 of URI/_server.pm, avg 815ns/call | |||||
# spent 14µs within URI::_server::CORE:regcomp which was called
# once (14µs+0s) by URI::_server::_uric_escape at line 10 of URI/_server.pm | |||||
# spent 221µs within URI::_server::CORE:subst which was called 453 times, avg 488ns/call:
# 123 times (86µs+0s) by URI::_server::host at line 87 of URI/_server.pm, avg 702ns/call
# 123 times (48µs+0s) by URI::_server::host at line 88 of URI/_server.pm, avg 393ns/call
# 123 times (46µs+0s) by URI::_server::host at line 89 of URI/_server.pm, avg 370ns/call
# 42 times (23µs+0s) by URI::_server::_uric_escape at line 12 of URI/_server.pm, avg 552ns/call
# 42 times (18µs+0s) by URI::_server::_uric_escape at line 13 of URI/_server.pm, avg 424ns/call |