← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/URI/_generic.pm
StatementsExecuted 58074 statements in 144ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
50052165.8ms102msURI::_generic::::pathURI::_generic::path
20021118.7ms22.0msURI::_generic::::_check_pathURI::_generic::_check_path
120124117.8ms17.8msURI::_generic::::CORE:matchURI::_generic::CORE:match (opcode)
30033116.1ms20.0msURI::_generic::::authorityURI::_generic::authority
2004311.76ms1.76msURI::_generic::::CORE:substURI::_generic::CORE:subst (opcode)
22130µs30µsURI::_generic::::CORE:regcompURI::_generic::CORE:regcomp (opcode)
1118µs8µsURI::_generic::::BEGIN@3URI::_generic::BEGIN@3
1118µs610µsURI::_generic::::BEGIN@6URI::_generic::BEGIN@6
1115µs20µsURI::_generic::::BEGIN@8URI::_generic::BEGIN@8
1113µs5µsURI::_generic::::BEGIN@4URI::_generic::BEGIN@4
1112µs2µsURI::_generic::::BEGIN@9URI::_generic::BEGIN@9
0000s0sURI::_generic::::_no_scheme_okURI::_generic::_no_scheme_ok
0000s0sURI::_generic::::_split_segmentURI::_generic::_split_segment
0000s0sURI::_generic::::absURI::_generic::abs
0000s0sURI::_generic::::path_queryURI::_generic::path_query
0000s0sURI::_generic::::path_segmentsURI::_generic::path_segments
0000s0sURI::_generic::::relURI::_generic::rel
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package URI::_generic;
2
3211µs210µs
# spent 8µs (8+1000ns) within URI::_generic::BEGIN@3 which was called: # once (8µs+1000ns) by parent::import at line 3
use strict;
# spent 8µs making 1 call to URI::_generic::BEGIN@3 # spent 1µs making 1 call to strict::import
4215µs27µs
# spent 5µs (3+2) within URI::_generic::BEGIN@4 which was called: # once (3µs+2µs) by parent::import at line 4
use warnings;
# spent 5µs making 1 call to URI::_generic::BEGIN@4 # spent 2µs making 1 call to warnings::import
5
6220µs2610µs
# spent 610µs (8+602) within URI::_generic::BEGIN@6 which was called: # once (8µs+602µs) by parent::import at line 6
use parent qw(URI URI::_query);
# spent 610µs making 1 call to URI::_generic::BEGIN@6 # spent 602µs making 1 call to parent::import, recursion: max depth 2, sum of overlapping time 602µs
7
8215µs235µs
# spent 20µs (5+15) within URI::_generic::BEGIN@8 which was called: # once (5µs+15µs) by parent::import at line 8
use URI::Escape qw(uri_unescape);
# spent 20µs making 1 call to URI::_generic::BEGIN@8 # spent 15µs making 1 call to Exporter::import
92783µs12µs
# spent 2µs within URI::_generic::BEGIN@9 which was called: # once (2µs+0s) by parent::import at line 9
use Carp ();
# spent 2µs making 1 call to URI::_generic::BEGIN@9
10
111400nsour $VERSION = "1.69";
12
13211µs14µsmy $ACHAR = $URI::uric; $ACHAR =~ s,\\[/?],,g;
# spent 4µs making 1 call to URI::_generic::CORE:subst
1422µs1600nsmy $PCHAR = $URI::uric; $PCHAR =~ s,\\[?],,g;
# spent 600ns making 1 call to URI::_generic::CORE:subst
15
16sub _no_scheme_ok { 1 }
17
18sub authority
19
# spent 20.0ms (16.1+3.82) within URI::_generic::authority which was called 3003 times, avg 7µs/call: # 1001 times (8.93ms+940µs) by URI::_server::_port at line 114 of URI/_server.pm, avg 10µs/call # 1001 times (5.32ms+2.10ms) by URI::_server::host at line 74 of URI/_server.pm, avg 7µs/call # 1001 times (1.90ms+780µs) by URI::_server::userinfo at line 54 of URI/_server.pm, avg 3µs/call
{
203003453µs my $self = shift;
21300315.0ms30043.82ms $$self =~ m,^((?:$URI::scheme_re:)?)(?://([^/?\#]*))?(.*)$,os or die;
# spent 3.80ms making 3003 calls to URI::_generic::CORE:match, avg 1µs/call # spent 16µs making 1 call to URI::_generic::CORE:regcomp
22
233003712µs if (@_) {
24 my $auth = shift;
25 $$self = $1;
26 my $rest = $3;
27 if (defined $auth) {
28 $auth =~ s/([^$ACHAR])/ URI::Escape::escape_char($1)/ego;
29 utf8::downgrade($auth);
30 $$self .= "//$auth";
31 }
32 _check_path($rest, $$self);
33 $$self .= $rest;
34 }
35300317.0ms $2;
36}
37
38sub path
39
# spent 102ms (65.8+35.8) within URI::_generic::path which was called 5005 times, avg 20µs/call: # 4004 times (61.8ms+34.0ms) by Search::Elasticsearch::Role::Cxn::build_uri at line 221 of Search/Elasticsearch/Role/Cxn.pm, avg 24µs/call # 1001 times (4.06ms+1.76ms) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 75 of Search/Elasticsearch/Role/Cxn.pm, avg 6µs/call
{
4050051.05ms my $self = shift;
41500534.6ms500510.8ms $$self =~ m,^((?:[^:/?\#]+:)?(?://[^/?\#]*)?)([^?\#]*)(.*)$,s or die;
# spent 10.8ms making 5005 calls to URI::_generic::CORE:match, avg 2µs/call
42
4350051.77ms if (@_) {
4420021.81ms $$self = $1;
4520021.39ms my $rest = $3;
462002778µs my $new_path = shift;
472002615µs $new_path = "" unless defined $new_path;
48200211.3ms20031.76ms $new_path =~ s/([^$PCHAR])/ URI::Escape::escape_char($1)/ego;
# spent 1.75ms making 2002 calls to URI::_generic::CORE:subst, avg 875ns/call # spent 14µs making 1 call to URI::_generic::CORE:regcomp
49200212.0ms20021.22ms utf8::downgrade($new_path);
# spent 1.22ms making 2002 calls to utf8::downgrade, avg 608ns/call
5020023.36ms200222.0ms _check_path($new_path, $$self);
# spent 22.0ms making 2002 calls to URI::_generic::_check_path, avg 11µs/call
5120022.44ms $$self .= $new_path . $rest;
52 }
53500515.9ms $2;
54}
55
56sub path_query
57{
58 my $self = shift;
59 $$self =~ m,^((?:[^:/?\#]+:)?(?://[^/?\#]*)?)([^\#]*)(.*)$,s or die;
60
61 if (@_) {
62 $$self = $1;
63 my $rest = $3;
64 my $new_path = shift;
65 $new_path = "" unless defined $new_path;
66 $new_path =~ s/([^$URI::uric])/ URI::Escape::escape_char($1)/ego;
67 utf8::downgrade($new_path);
68 _check_path($new_path, $$self);
69 $$self .= $new_path . $rest;
70 }
71 $2;
72}
73
74sub _check_path
75
# spent 22.0ms (18.7+3.22) within URI::_generic::_check_path which was called 2002 times, avg 11µs/call: # 2002 times (18.7ms+3.22ms) by URI::_generic::path at line 50, avg 11µs/call
{
7620021.22ms my($path, $pre) = @_;
772002410µs my $prefix;
7820025.30ms20021.63ms if ($pre =~ m,/,) { # authority present
# spent 1.63ms making 2002 calls to URI::_generic::CORE:match, avg 813ns/call
79200211.9ms20021.59ms $prefix = "/" if length($path) && $path !~ m,^[/?\#],;
# spent 1.59ms making 2002 calls to URI::_generic::CORE:match, avg 795ns/call
80 }
81 else {
82 if ($path =~ m,^//,) {
83 Carp::carp("Path starting with double slash is confusing")
84 if $^W;
85 }
86 elsif (!length($pre) && $path =~ m,^[^:/?\#]+:,) {
87 Carp::carp("Path might look like scheme, './' prepended")
88 if $^W;
89 $prefix = "./";
90 }
91 }
9220024.30ms substr($_[0], 0, 0) = $prefix if defined $prefix;
93}
94
95sub path_segments
96{
97 my $self = shift;
98 my $path = $self->path;
99 if (@_) {
100 my @arg = @_; # make a copy
101 for (@arg) {
102 if (ref($_)) {
103 my @seg = @$_;
104 $seg[0] =~ s/%/%25/g;
105 for (@seg) { s/;/%3B/g; }
106 $_ = join(";", @seg);
107 }
108 else {
109 s/%/%25/g; s/;/%3B/g;
110 }
111 s,/,%2F,g;
112 }
113 $self->path(join("/", @arg));
114 }
115 return $path unless wantarray;
116 map {/;/ ? $self->_split_segment($_)
117 : uri_unescape($_) }
118 split('/', $path, -1);
119}
120
121
122sub _split_segment
123{
124 my $self = shift;
125 require URI::_segment;
126 URI::_segment->new(@_);
127}
128
129
130sub abs
131{
132 my $self = shift;
133 my $base = shift || Carp::croak("Missing base argument");
134
135 if (my $scheme = $self->scheme) {
136 return $self unless $URI::ABS_ALLOW_RELATIVE_SCHEME;
137 $base = URI->new($base) unless ref $base;
138 return $self unless $scheme eq $base->scheme;
139 }
140
141 $base = URI->new($base) unless ref $base;
142 my $abs = $self->clone;
143 $abs->scheme($base->scheme);
144 return $abs if $$self =~ m,^(?:$URI::scheme_re:)?//,o;
145 $abs->authority($base->authority);
146
147 my $path = $self->path;
148 return $abs if $path =~ m,^/,;
149
150 if (!length($path)) {
151 my $abs = $base->clone;
152 my $query = $self->query;
153 $abs->query($query) if defined $query;
154 my $fragment = $self->fragment;
155 $abs->fragment($fragment) if defined $fragment;
156 return $abs;
157 }
158
159 my $p = $base->path;
160 $p =~ s,[^/]+$,,;
161 $p .= $path;
162 my @p = split('/', $p, -1);
163 shift(@p) if @p && !length($p[0]);
164 my $i = 1;
165 while ($i < @p) {
166 #print "$i ", join("/", @p), " ($p[$i])\n";
167 if ($p[$i-1] eq ".") {
168 splice(@p, $i-1, 1);
169 $i-- if $i > 1;
170 }
171 elsif ($p[$i] eq ".." && $p[$i-1] ne "..") {
172 splice(@p, $i-1, 2);
173 if ($i > 1) {
174 $i--;
175 push(@p, "") if $i == @p;
176 }
177 }
178 else {
179 $i++;
180 }
181 }
182 $p[-1] = "" if @p && $p[-1] eq "."; # trailing "/."
183 if ($URI::ABS_REMOTE_LEADING_DOTS) {
184 shift @p while @p && $p[0] =~ /^\.\.?$/;
185 }
186 $abs->path("/" . join("/", @p));
187 $abs;
188}
189
190# The opposite of $url->abs. Return a URI which is as relative as possible
191sub rel {
192 my $self = shift;
193 my $base = shift || Carp::croak("Missing base argument");
194 my $rel = $self->clone;
195 $base = URI->new($base) unless ref $base;
196
197 #my($scheme, $auth, $path) = @{$rel}{qw(scheme authority path)};
198 my $scheme = $rel->scheme;
199 my $auth = $rel->canonical->authority;
200 my $path = $rel->path;
201
202 if (!defined($scheme) && !defined($auth)) {
203 # it is already relative
204 return $rel;
205 }
206
207 #my($bscheme, $bauth, $bpath) = @{$base}{qw(scheme authority path)};
208 my $bscheme = $base->scheme;
209 my $bauth = $base->canonical->authority;
210 my $bpath = $base->path;
211
212 for ($bscheme, $bauth, $auth) {
213 $_ = '' unless defined
214 }
215
216 unless ($scheme eq $bscheme && $auth eq $bauth) {
217 # different location, can't make it relative
218 return $rel;
219 }
220
221 for ($path, $bpath) { $_ = "/$_" unless m,^/,; }
222
223 # Make it relative by eliminating scheme and authority
224 $rel->scheme(undef);
225 $rel->authority(undef);
226
227 # This loop is based on code from Nicolai Langfeldt <janl@ifi.uio.no>.
228 # First we calculate common initial path components length ($li).
229 my $li = 1;
230 while (1) {
231 my $i = index($path, '/', $li);
232 last if $i < 0 ||
233 $i != index($bpath, '/', $li) ||
234 substr($path,$li,$i-$li) ne substr($bpath,$li,$i-$li);
235 $li=$i+1;
236 }
237 # then we nuke it from both paths
238 substr($path, 0,$li) = '';
239 substr($bpath,0,$li) = '';
240
241 if ($path eq $bpath &&
242 defined($rel->fragment) &&
243 !defined($rel->query)) {
244 $rel->path("");
245 }
246 else {
247 # Add one "../" for each path component left in the base path
248 $path = ('../' x $bpath =~ tr|/|/|) . $path;
249 $path = "./" if $path eq "";
250 $rel->path($path);
251 }
252
253 $rel;
254}
255
25614µs1;
 
# spent 17.8ms within URI::_generic::CORE:match which was called 12012 times, avg 1µs/call: # 5005 times (10.8ms+0s) by URI::_generic::path at line 41, avg 2µs/call # 3003 times (3.80ms+0s) by URI::_generic::authority at line 21, avg 1µs/call # 2002 times (1.63ms+0s) by URI::_generic::_check_path at line 78, avg 813ns/call # 2002 times (1.59ms+0s) by URI::_generic::_check_path at line 79, avg 795ns/call
sub URI::_generic::CORE:match; # opcode
# spent 30µs within URI::_generic::CORE:regcomp which was called 2 times, avg 15µs/call: # once (16µs+0s) by URI::_generic::authority at line 21 # once (14µs+0s) by URI::_generic::path at line 48
sub URI::_generic::CORE:regcomp; # opcode
# spent 1.76ms within URI::_generic::CORE:subst which was called 2004 times, avg 876ns/call: # 2002 times (1.75ms+0s) by URI::_generic::path at line 48, avg 875ns/call # once (4µs+0s) by parent::import at line 13 # once (600ns+0s) by parent::import at line 14
sub URI::_generic::CORE:subst; # opcode