← Index
NYTProf Performance Profile   « line view »
For flows_to_es.pl
  Run on Mon May 9 23:27:59 2016
Reported on Mon May 9 23:28:09 2016

Filename/usr/share/perl5/URI/_server.pm
StatementsExecuted 53 statements in 1.57ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
211699µs2.83msURI::_server::::_host_escapeURI::_server::_host_escape
21154µs2.97msURI::_server::::_uric_escapeURI::_server::_uric_escape
21121µs21µsURI::_server::::CORE:regcompURI::_server::CORE:regcomp (opcode)
11118µs134µsURI::_server::::hostURI::_server::host
11112µs26µsURI::_server::::BEGIN@5URI::_server::BEGIN@5
11112µs19µsURI::_server::::userinfoURI::_server::userinfo
11111µs50µsURI::_server::::BEGIN@6URI::_server::BEGIN@6
64110µs10µsURI::_server::::CORE:matchURI::_server::CORE:match (opcode)
1119µs19µsURI::_server::::_portURI::_server::_port
1116µs26µsURI::_server::::portURI::_server::port
7516µs6µsURI::_server::::CORE:substURI::_server::CORE:subst (opcode)
0000s0sURI::_server::::as_iriURI::_server::as_iri
0000s0sURI::_server::::canonicalURI::_server::canonical
0000s0sURI::_server::::default_portURI::_server::default_port
0000s0sURI::_server::::host_portURI::_server::host_port
0000s0sURI::_server::::ihostURI::_server::ihost
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package URI::_server;
2197µsrequire URI::_generic;
315µs@ISA=qw(URI::_generic);
4
5231µs241µ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
use strict;
# spent 26µs making 1 call to URI::_server::BEGIN@5 # spent 14µs making 1 call to strict::import
621.21ms289µ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
use URI::Escape qw(uri_unescape);
# 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
sub _uric_escape {
92700ns my($class, $str) = @_;
10244µs427µ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
1126µs my($scheme, $host, $rest) = ($1, $2, $3);
1227µs21µs my $ui = $host =~ s/(.*@)// ? $1 : "";
# spent 1µs making 2 calls to URI::_server::CORE:subst, avg 500ns/call
1328µs23µs my $port = $host =~ s/(:\d+)\z// ? $1 : "";
# spent 3µs making 2 calls to URI::_server::CORE:subst, avg 1µs/call
1425µs22.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 }
18211µs254µ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
sub _host_escape {
2226µs22µs return unless $_[0] =~ /[^URI::uric]/;
# spent 2µs making 2 calls to URI::_server::CORE:match, avg 900ns/call
2321µs eval {
24282µs require URI::_idna;
2525µs2118µs $_[0] = URI::_idna::encode($_[0]);
# spent 118µs making 2 calls to URI::_idna::encode, avg 59µs/call
26 };
272400ns return 0 if $@;
2825µs return 1;
29}
30
31sub 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
47sub 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
{
491200ns my $self = shift;
5015µs17µs my $old = $self->authority;
# spent 7µs making 1 call to URI::_generic::authority
51
521200ns 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 }
6316µs1400ns return undef if !defined($old) || $old !~ /(.*)@/;
# spent 400ns making 1 call to URI::_server::CORE:match
64 return $1;
65}
66
67sub 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
{
691300ns my $self = shift;
7014µs1106µs my $old = $self->authority;
# spent 106µs making 1 call to URI::_generic::authority
711200ns 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 }
891200ns return undef unless defined $old;
9013µs1500ns $old =~ s/.*@//;
# spent 500ns making 1 call to URI::_server::CORE:subst
9114µs12µs $old =~ s/:\d+$//; # remove the port
# spent 2µs making 1 call to URI::_server::CORE:subst
9213µs1300ns $old =~ s{^\[(.*)\]$}{$1}; # remove brackets around IPv6 (RFC 3986 3.2.2)
# spent 300ns making 1 call to URI::_server::CORE:subst
9315µs18µs return uri_unescape($old);
# spent 8µs making 1 call to URI::Escape::uri_unescape
94}
95
96sub 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
107sub _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
{
1091200ns my $self = shift;
11011µs19µs my $old = $self->authority;
# spent 9µs making 1 call to URI::_generic::authority
1111200ns if (@_) {
112 my $new = $old;
113 $new =~ s/:\d*$//;
114 my $port = shift;
115 $new .= ":$port" if defined $port;
116 $self->authority($new);
117 }
11818µs12µs return $1 if defined($old) && $old =~ /:(\d*)$/;
# spent 2µs making 1 call to URI::_server::CORE:match
119 return;
120}
121
122sub 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
{
1241300ns my $self = shift;
12512µs119µs my $port = $self->_port(@_);
# spent 19µs making 1 call to URI::_server::_port
1261500ns $port = $self->default_port if !defined($port) || $port eq "";
12713µs $port;
128}
129
130sub 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
143sub default_port { undef }
144
145sub 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
16212µs1;
 
# 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
sub URI::_server::CORE:match; # opcode
# 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
sub URI::_server::CORE:regcomp; # opcode
# 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
sub URI::_server::CORE:subst; # opcode