← 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.pm
StatementsExecuted 71103 statements in 207ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
20022166.2ms180msURI::::newURI::new
20021116.5ms20.4msURI::::implementorURI::implementor
20021113.1ms86.7msURI::::_initURI::_init
10011112.4ms18.1msURI::::schemeURI::scheme
2002119.22ms11.8msURI::::_uric_escapeURI::_uric_escape
6006228.64ms8.64msURI::::__ANON__[:24]URI::__ANON__[:24]
2002116.75ms6.75msURI::::cloneURI::clone
7007415.92ms5.92msURI::::CORE:matchURI::CORE:match (opcode)
10013815.39ms5.39msURI::::CORE:substURI::CORE:subst (opcode)
1001114.72ms5.78msURI::::_schemeURI::_scheme
111585µs618µsURI::::BEGIN@22URI::BEGIN@22
55166µs66µsURI::::CORE:regcompURI::CORE:regcomp (opcode)
11110µs36µsURI::::BEGIN@24URI::BEGIN@24
1118µs9µsURI::::BEGIN@3URI::BEGIN@3
1116µs17µsURI::::BEGIN@128URI::BEGIN@128
1114µs7µsURI::::BEGIN@4URI::BEGIN@4
1113µs3µsURI::::_init_implementorURI::_init_implementor
1112µs2µsURI::::BEGIN@21URI::BEGIN@21
0000s0sURI::::STORABLE_freezeURI::STORABLE_freeze
0000s0sURI::::STORABLE_thawURI::STORABLE_thaw
0000s0sURI::::TO_JSONURI::TO_JSON
0000s0sURI::::__ANON__[:25]URI::__ANON__[:25]
0000s0sURI::::__ANON__[:26]URI::__ANON__[:26]
0000s0sURI::::_no_scheme_okURI::_no_scheme_ok
0000s0sURI::::_obj_eqURI::_obj_eq
0000s0sURI::::absURI::abs
0000s0sURI::::as_iriURI::as_iri
0000s0sURI::::as_stringURI::as_string
0000s0sURI::::canonicalURI::canonical
0000s0sURI::::eqURI::eq
0000s0sURI::::fragmentURI::fragment
0000s0sURI::::has_recognized_schemeURI::has_recognized_scheme
0000s0sURI::::new_absURI::new_abs
0000s0sURI::::opaqueURI::opaque
0000s0sURI::::pathURI::path
0000s0sURI::::relURI::rel
0000s0sURI::::secureURI::secure
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package URI;
2
3214µs211µs
# spent 9µs (8+1) within URI::BEGIN@3 which was called: # once (8µs+1µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 3
use strict;
# spent 9µs making 1 call to URI::BEGIN@3 # spent 1µs making 1 call to strict::import
4260µs210µs
# spent 7µs (4+3) within URI::BEGIN@4 which was called: # once (4µs+3µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 4
use warnings;
# spent 7µs making 1 call to URI::BEGIN@4 # spent 3µs making 1 call to warnings::import
5
61300nsour $VERSION = "1.69";
7
8our ($ABS_REMOTE_LEADING_DOTS, $ABS_ALLOW_RELATIVE_SCHEME, $DEFAULT_QUERY_FORM_DELIMITER);
9
101100nsmy %implements; # mapping from scheme to implementor class
11
12# Some "official" character classes
13
141100nsour $reserved = q(;/?:@&=+$,[]);
151200nsour $mark = q(-_.!~*'()); #'; emacs
161800nsour $unreserved = "A-Za-z0-9\Q$mark\E";
171600nsour $uric = quotemeta($reserved) . $unreserved . "%";
18
191100nsour $scheme_re = '[a-zA-Z][a-zA-Z0-9.+\-]*';
20
21213µs12µs
# spent 2µs within URI::BEGIN@21 which was called: # once (2µs+0s) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 21
use Carp ();
# spent 2µs making 1 call to URI::BEGIN@21
222120µs1618µs
# spent 618µs (585+33) within URI::BEGIN@22 which was called: # once (585µs+33µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 22
use URI::Escape ();
# spent 618µs making 1 call to URI::BEGIN@22
23
24600646.5ms
# spent 8.64ms within URI::__ANON__[/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/URI.pm:24] which was called 6006 times, avg 1µs/call: # 4004 times (6.22ms+0s) by Search::Elasticsearch::Role::Cxn::stringify at line 56 of Search/Elasticsearch/Role/Cxn.pm, avg 2µs/call # 2002 times (2.42ms+0s) by Search::Elasticsearch::Cxn::HTTPTiny::perform_request at line 34 of Search/Elasticsearch/Cxn/HTTPTiny.pm, avg 1µs/call # spent 36µs (10+26) within URI::BEGIN@24 which was called: # once (10µs+26µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 28
use overload ('""' => sub { ${$_[0]} },
25 '==' => sub { _obj_eq(@_) },
26 '!=' => sub { !_obj_eq(@_) },
2716µs126µs fallback => 1,
# spent 26µs making 1 call to overload::import
281291µs136µs );
# spent 36µs making 1 call to URI::BEGIN@24
29
30# Check if two objects are the same object
31sub _obj_eq {
32 return overload::StrVal($_[0]) eq overload::StrVal($_[1]);
33}
34
35sub new
36
# spent 180ms (66.2+113) within URI::new which was called 2002 times, avg 90µs/call: # 1001 times (35.0ms+70.0ms) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 74 of Search/Elasticsearch/Role/Cxn.pm, avg 105µs/call # 1001 times (31.2ms+43.4ms) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 119 of Search/Elasticsearch/Role/Cxn.pm, avg 75µs/call
{
372002924µs my($class, $uri, $scheme) = @_;
38
3920021.79ms $uri = defined ($uri) ? "$uri" : ""; # stringify
40 # Get rid of potential wrapping
41200211.9ms2002980µs $uri =~ s/^<(?:URL:)?(.*)>$/$1/; #
# spent 980µs making 2002 calls to URI::CORE:subst, avg 490ns/call
42200216.9ms2002602µs $uri =~ s/^"(.*)"$/$1/;
# spent 602µs making 2002 calls to URI::CORE:subst, avg 301ns/call
4320023.35ms20021.26ms $uri =~ s/^\s+//;
# spent 1.26ms making 2002 calls to URI::CORE:subst, avg 628ns/call
44200211.9ms20021.51ms $uri =~ s/\s+$//;
# spent 1.51ms making 2002 calls to URI::CORE:subst, avg 755ns/call
45
462002364µs my $impclass;
4720026.71ms20031.91ms if ($uri =~ m/^($scheme_re):/so) {
# spent 1.89ms making 2002 calls to URI::CORE:match, avg 943ns/call # spent 19µs making 1 call to URI::CORE:regcomp
48 $scheme = $1;
49 }
50 else {
51 if (($impclass = ref($scheme))) {
52 $scheme = $scheme->scheme;
53 }
54 elsif ($scheme && $scheme =~ m/^($scheme_re)(?::|$)/o) {
55 $scheme = $1;
56 }
57 }
58 $impclass ||= implementor($scheme) ||
5920023.75ms200220.4ms do {
# spent 20.4ms making 2002 calls to URI::implementor, avg 10µs/call
60 require URI::_foreign;
61 $impclass = 'URI::_foreign';
62 };
63
64200223.1ms200286.7ms return $impclass->_init($uri, $scheme);
# spent 86.7ms making 2002 calls to URI::_init, avg 43µs/call
65}
66
67
68sub new_abs
69{
70 my($class, $uri, $base) = @_;
71 $uri = $class->new($uri, $base);
72 $uri->abs($base);
73}
74
75
76sub _init
77
# spent 86.7ms (13.1+73.6) within URI::_init which was called 2002 times, avg 43µs/call: # 2002 times (13.1ms+73.6ms) by URI::new at line 64, avg 43µs/call
{
782002601µs my $class = shift;
792002875µs my($str, $scheme) = @_;
80 # find all funny characters and encode the bytes.
8120024.19ms200272.1ms $str = $class->_uric_escape($str);
# spent 72.1ms making 2002 calls to URI::_server::_uric_escape, avg 36µs/call
8220024.10ms20031.44ms $str = "$scheme:$str" unless $str =~ /^$scheme_re:/o ||
# spent 1.43ms making 2002 calls to URI::CORE:match, avg 716ns/call # spent 7µs making 1 call to URI::CORE:regcomp
83 $class->_no_scheme_ok;
8420021.73ms my $self = bless \$str, $class;
8520023.18ms $self;
86}
87
88
89sub _uric_escape
90
# spent 11.8ms (9.22+2.62) within URI::_uric_escape which was called 2002 times, avg 6µs/call: # 2002 times (9.22ms+2.62ms) by URI::_server::_uric_escape at line 22 of URI/_server.pm, avg 6µs/call
{
912002621µs my($class, $str) = @_;
9220023.50ms20031.05ms $str =~ s*([^$uric\#])* URI::Escape::escape_char($1) *ego;
# spent 1.04ms making 2002 calls to URI::CORE:subst, avg 521ns/call # spent 12µs making 1 call to URI::CORE:regcomp
9320025.43ms20021.56ms utf8::downgrade($str);
# spent 1.56ms making 2002 calls to utf8::downgrade, avg 780ns/call
9420023.50ms return $str;
95}
96
97
98sub implementor
99
# spent 20.4ms (16.5+3.91) within URI::implementor which was called 2002 times, avg 10µs/call: # 2002 times (16.5ms+3.91ms) by URI::new at line 59, avg 10µs/call
{
1002002808µs my($scheme, $impclass) = @_;
101200210.1ms20031.57ms if (!$scheme || $scheme !~ /\A$scheme_re\z/o) {
# spent 1.55ms making 2002 calls to URI::CORE:match, avg 775ns/call # spent 18µs making 1 call to URI::CORE:regcomp
102 require URI::_generic;
103 return "URI::_generic";
104 }
105
10620021.46ms $scheme = lc($scheme);
107
1082002464µs if ($impclass) {
109 # Set the implementor class for a given scheme
110 my $old = $implements{$scheme};
111 $impclass->_init_implementor($scheme);
112 $implements{$scheme} = $impclass;
113 return $old;
114 }
115
11620021.70ms my $ic = $implements{$scheme};
11720029.64ms return $ic if $ic;
118
119 # scheme not yet known, look for internal or
120 # preloaded (with 'use') implementation
1211600ns $ic = "URI::$scheme"; # default location
122
123 # turn scheme into a valid perl identifier by a simple transformation...
12411µs1300ns $ic =~ s/\+/_P/g;
# spent 300ns making 1 call to URI::CORE:subst
12512µs1200ns $ic =~ s/\./_O/g;
# spent 200ns making 1 call to URI::CORE:subst
12612µs1200ns $ic =~ s/\-/_/g;
# spent 200ns making 1 call to URI::CORE:subst
127
1282616µs229µs
# spent 17µs (6+12) within URI::BEGIN@128 which was called: # once (6µs+12µs) by Search::Elasticsearch::Role::Logger::BEGIN@5 at line 128
no strict 'refs';
# spent 17µs making 1 call to URI::BEGIN@128 # spent 12µs making 1 call to strict::unimport
129 # check we actually have one for the scheme:
13014µs unless (@{"${ic}::ISA"}) {
131 # Try to load it
132118µs eval "require $ic";
# spent 45µs executing statements in string eval
1331300ns die $@ if $@ && $@ !~ /Can\'t locate.*in \@INC/;
13411µs return undef unless @{"${ic}::ISA"};
135 }
136
13714µs13µs $ic->_init_implementor($scheme);
# spent 3µs making 1 call to URI::_init_implementor
13811µs $implements{$scheme} = $ic;
13912µs $ic;
140}
141
142
143sub _init_implementor
144
# spent 3µs within URI::_init_implementor which was called: # once (3µs+0s) by URI::implementor at line 137
{
14515µs my($class, $scheme) = @_;
146 # Remember that one implementor class may actually
147 # serve to implement several URI schemes.
148}
149
150
151sub clone
152
# spent 6.75ms within URI::clone which was called 2002 times, avg 3µs/call: # 2002 times (6.75ms+0s) by Search::Elasticsearch::Role::Cxn::build_uri at line 220 of Search/Elasticsearch/Role/Cxn.pm, avg 3µs/call
{
1532002703µs my $self = shift;
15420021.13ms my $other = $$self;
15520026.25ms bless \$other, ref $self;
156}
157
158sub TO_JSON { ${$_[0]} }
159
160sub _no_scheme_ok { 0 }
161
162sub _scheme
163
# spent 5.78ms (4.72+1.05) within URI::_scheme which was called 1001 times, avg 6µs/call: # 1001 times (4.72ms+1.05ms) by URI::scheme at line 196, avg 6µs/call
{
1641001355µs my $self = shift;
165
1661001556µs unless (@_) {
16710012.86ms10021.05ms return undef unless $$self =~ /^($scheme_re):/o;
# spent 1.04ms making 1001 calls to URI::CORE:match, avg 1µs/call # spent 11µs making 1 call to URI::CORE:regcomp
16810019.76ms return $1;
169 }
170
171 my $old;
172 my $new = shift;
173 if (defined($new) && length($new)) {
174 Carp::croak("Bad scheme '$new'") unless $new =~ /^$scheme_re$/o;
175 $old = $1 if $$self =~ s/^($scheme_re)://o;
176 my $newself = URI->new("$new:$$self");
177 $$self = $$newself;
178 bless $self, ref($newself);
179 }
180 else {
181 if ($self->_no_scheme_ok) {
182 $old = $1 if $$self =~ s/^($scheme_re)://o;
183 Carp::carp("Oops, opaque part now look like scheme")
184 if $^W && $$self =~ m/^$scheme_re:/o
185 }
186 else {
187 $old = $1 if $$self =~ m/^($scheme_re):/o;
188 }
189 }
190
191 return $old;
192}
193
194sub scheme
195
# spent 18.1ms (12.4+5.78) within URI::scheme which was called 1001 times, avg 18µs/call: # 1001 times (12.4ms+5.78ms) by Search::Elasticsearch::Role::Cxn::BUILDARGS at line 75 of Search/Elasticsearch/Role/Cxn.pm, avg 18µs/call
{
19610012.40ms10015.78ms my $scheme = shift->_scheme(@_);
# spent 5.78ms making 1001 calls to URI::_scheme, avg 6µs/call
1971001608µs return undef unless defined $scheme;
19810011.75ms lc($scheme);
199}
200
201sub has_recognized_scheme {
202 my $self = shift;
203 return ref($self) !~ /^URI::_(?:foreign|generic)\z/;
204}
205
206sub opaque
207{
208 my $self = shift;
209
210 unless (@_) {
211 $$self =~ /^(?:$scheme_re:)?([^\#]*)/o or die;
212 return $1;
213 }
214
215 $$self =~ /^($scheme_re:)? # optional scheme
216 ([^\#]*) # opaque
217 (\#.*)? # optional fragment
218 $/sx or die;
219
220 my $old_scheme = $1;
221 my $old_opaque = $2;
222 my $old_frag = $3;
223
224 my $new_opaque = shift;
225 $new_opaque = "" unless defined $new_opaque;
226 $new_opaque =~ s/([^$uric])/ URI::Escape::escape_char($1)/ego;
227 utf8::downgrade($new_opaque);
228
229 $$self = defined($old_scheme) ? $old_scheme : "";
230 $$self .= $new_opaque;
231 $$self .= $old_frag if defined $old_frag;
232
233 $old_opaque;
234}
235
236sub path { goto &opaque } # alias
237
238
239sub fragment
240{
241 my $self = shift;
242 unless (@_) {
243 return undef unless $$self =~ /\#(.*)/s;
244 return $1;
245 }
246
247 my $old;
248 $old = $1 if $$self =~ s/\#(.*)//s;
249
250 my $new_frag = shift;
251 if (defined $new_frag) {
252 $new_frag =~ s/([^$uric])/ URI::Escape::escape_char($1) /ego;
253 utf8::downgrade($new_frag);
254 $$self .= "#$new_frag";
255 }
256 $old;
257}
258
259
260sub as_string
261{
262 my $self = shift;
263 $$self;
264}
265
266
267sub as_iri
268{
269 my $self = shift;
270 my $str = $$self;
271 if ($str =~ s/%([89a-fA-F][0-9a-fA-F])/chr(hex($1))/eg) {
272 # All this crap because the more obvious:
273 #
274 # Encode::decode("UTF-8", $str, sub { sprintf "%%%02X", shift })
275 #
276 # doesn't work before Encode 2.39. Wait for a standard release
277 # to bundle that version.
278
279 require Encode;
280 my $enc = Encode::find_encoding("UTF-8");
281 my $u = "";
282 while (length $str) {
283 $u .= $enc->decode($str, Encode::FB_QUIET());
284 if (length $str) {
285 # escape next char
286 $u .= URI::Escape::escape_char(substr($str, 0, 1, ""));
287 }
288 }
289 $str = $u;
290 }
291 return $str;
292}
293
294
295sub canonical
296{
297 # Make sure scheme is lowercased, that we don't escape unreserved chars,
298 # and that we use upcase escape sequences.
299
300 my $self = shift;
301 my $scheme = $self->_scheme || "";
302 my $uc_scheme = $scheme =~ /[A-Z]/;
303 my $esc = $$self =~ /%[a-fA-F0-9]{2}/;
304 return $self unless $uc_scheme || $esc;
305
306 my $other = $self->clone;
307 if ($uc_scheme) {
308 $other->_scheme(lc $scheme);
309 }
310 if ($esc) {
311 $$other =~ s{%([0-9a-fA-F]{2})}
312 { my $a = chr(hex($1));
313 $a =~ /^[$unreserved]\z/o ? $a : "%\U$1"
314 }ge;
315 }
316 return $other;
317}
318
319# Compare two URIs, subclasses will provide a more correct implementation
320sub eq {
321 my($self, $other) = @_;
322 $self = URI->new($self, $other) unless ref $self;
323 $other = URI->new($other, $self) unless ref $other;
324 ref($self) eq ref($other) && # same class
325 $self->canonical->as_string eq $other->canonical->as_string;
326}
327
328# generic-URI transformation methods
329sub abs { $_[0]; }
330sub rel { $_[0]; }
331
332sub secure { 0 }
333
334# help out Storable
335sub STORABLE_freeze {
336 my($self, $cloning) = @_;
337 return $$self;
338}
339
340sub STORABLE_thaw {
341 my($self, $cloning, $str) = @_;
342 $$self = $str;
343}
344
34514µs1;
346
347__END__
 
# spent 5.92ms within URI::CORE:match which was called 7007 times, avg 844ns/call: # 2002 times (1.89ms+0s) by URI::new at line 47, avg 943ns/call # 2002 times (1.55ms+0s) by URI::implementor at line 101, avg 775ns/call # 2002 times (1.43ms+0s) by URI::_init at line 82, avg 716ns/call # 1001 times (1.04ms+0s) by URI::_scheme at line 167, avg 1µs/call
sub URI::CORE:match; # opcode
# spent 66µs within URI::CORE:regcomp which was called 5 times, avg 13µs/call: # once (19µs+0s) by URI::new at line 47 # once (18µs+0s) by URI::implementor at line 101 # once (12µs+0s) by URI::_uric_escape at line 92 # once (11µs+0s) by URI::_scheme at line 167 # once (7µs+0s) by URI::_init at line 82
sub URI::CORE:regcomp; # opcode
# spent 5.39ms within URI::CORE:subst which was called 10013 times, avg 539ns/call: # 2002 times (1.51ms+0s) by URI::new at line 44, avg 755ns/call # 2002 times (1.26ms+0s) by URI::new at line 43, avg 628ns/call # 2002 times (1.04ms+0s) by URI::_uric_escape at line 92, avg 521ns/call # 2002 times (980µs+0s) by URI::new at line 41, avg 490ns/call # 2002 times (602µs+0s) by URI::new at line 42, avg 301ns/call # once (300ns+0s) by URI::implementor at line 124 # once (200ns+0s) by URI::implementor at line 126 # once (200ns+0s) by URI::implementor at line 125
sub URI::CORE:subst; # opcode