← 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/_query.pm
StatementsExecuted 52062 statements in 61.0ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
20021136.2ms59.8msURI::_query::::query_formURI::_query::query_form
40042116.8ms22.1msURI::_query::::queryURI::_query::query
4004115.36ms5.36msURI::_query::::CORE:matchURI::_query::CORE:match (opcode)
2002111.48ms1.48msURI::_query::::CORE:sortURI::_query::CORE:sort (opcode)
1118µs9µsURI::_query::::BEGIN@3URI::_query::BEGIN@3
1115µs32µsURI::_query::::BEGIN@7URI::_query::BEGIN@7
1113µs5µsURI::_query::::BEGIN@4URI::_query::BEGIN@4
1112µs2µsURI::_query::::BEGIN@6URI::_query::BEGIN@6
0000s0sURI::_query::::equeryURI::_query::equery
0000s0sURI::_query::::query_keywordsURI::_query::query_keywords
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package URI::_query;
2
3212µs210µs
# spent 9µs (8+1000ns) within URI::_query::BEGIN@3 which was called: # once (8µs+1000ns) by parent::import at line 3
use strict;
# spent 9µs making 1 call to URI::_query::BEGIN@3 # spent 1µs making 1 call to strict::import
4211µs27µs
# spent 5µs (3+2) within URI::_query::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::_query::BEGIN@4 # spent 2µs making 1 call to warnings::import
5
6212µs12µs
# spent 2µs within URI::_query::BEGIN@6 which was called: # once (2µs+0s) by parent::import at line 6
use URI ();
# spent 2µs making 1 call to URI::_query::BEGIN@6
72477µs259µs
# spent 32µs (5+27) within URI::_query::BEGIN@7 which was called: # once (5µs+27µs) by parent::import at line 7
use URI::Escape qw(uri_unescape);
# spent 32µs making 1 call to URI::_query::BEGIN@7 # spent 27µs making 1 call to Exporter::import
8
91200nsour $VERSION = "1.69";
10
11sub query
12
# spent 22.1ms (16.8+5.36) within URI::_query::query which was called 4004 times, avg 6µs/call: # 2002 times (8.48ms+3.68ms) by URI::_query::query_form at line 32, avg 6µs/call # 2002 times (8.29ms+1.68ms) by URI::_query::query_form at line 68, avg 5µs/call
{
134004917µs my $self = shift;
14400411.8ms40045.36ms $$self =~ m,^([^?\#]*)(?:\?([^\#]*))?(.*)$,s or die;
# spent 5.36ms making 4004 calls to URI::_query::CORE:match, avg 1µs/call
15
1640041.44ms if (@_) {
172002519µs my $q = shift;
1820021.46ms $$self = $1;
192002849µs if (defined $q) {
20 $q =~ s/([^$URI::uric])/ URI::Escape::escape_char($1)/ego;
21 utf8::downgrade($q);
22 $$self .= "?$q";
23 }
2420021.76ms $$self .= $3;
25 }
26400413.1ms $2;
27}
28
29# Handle ...?foo=bar&bar=foo type of query
30
# spent 59.8ms (36.2+23.6) within URI::_query::query_form which was called 2002 times, avg 30µs/call: # 2002 times (36.2ms+23.6ms) by Search::Elasticsearch::Role::Cxn::build_uri at line 223 of Search/Elasticsearch/Role/Cxn.pm, avg 30µs/call
sub query_form {
312002638µs my $self = shift;
3220023.41ms200212.2ms my $old = $self->query;
# spent 12.2ms making 2002 calls to URI::_query::query, avg 6µs/call
3320021.11ms if (@_) {
34 # Try to set query string
352002349µs my $delim;
362002757µs my $r = $_[0];
3720022.79ms if (ref($r) eq "ARRAY") {
38 $delim = $_[1];
39 @_ = @$r;
40 }
41 elsif (ref($r) eq "HASH") {
422002653µs $delim = $_[1];
4320026.52ms20021.48ms @_ = map { $_ => $r->{$_} } sort keys %$r;
# spent 1.48ms making 2002 calls to URI::_query::CORE:sort, avg 738ns/call
44 }
4520021.24ms $delim = pop if @_ % 2;
46
472002412µs my @query;
4820023.32ms while (my($key,$vals) = splice(@_, 0, 2)) {
49 $key = '' unless defined $key;
50 $key =~ s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg;
51 $key =~ s/ /+/g;
52 $vals = [ref($vals) eq "ARRAY" ? @$vals : $vals];
53 for my $val (@$vals) {
54 $val = '' unless defined $val;
55 $val =~ s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg;
56 $val =~ s/ /+/g;
57 push(@query, "$key=$val");
58 }
59 }
6020021.53ms if (@query) {
61 unless ($delim) {
62 $delim = $1 if $old && $old =~ /([&;])/;
63 $delim ||= $URI::DEFAULT_QUERY_FORM_DELIMITER || "&";
64 }
65 $self->query(join($delim, @query));
66 }
67 else {
6820021.79ms20029.98ms $self->query(undef);
# spent 9.98ms making 2002 calls to URI::_query::query, avg 5µs/call
69 }
70 }
7120024.17ms return if !defined($old) || !length($old) || !defined(wantarray);
72 return unless $old =~ /=/; # not a form
73 map { s/\+/ /g; uri_unescape($_) }
74 map { /=/ ? split(/=/, $_, 2) : ($_ => '')} split(/[&;]/, $old);
75}
76
77# Handle ...?dog+bones type of query
78sub query_keywords
79{
80 my $self = shift;
81 my $old = $self->query;
82 if (@_) {
83 # Try to set query string
84 my @copy = @_;
85 @copy = @{$copy[0]} if @copy == 1 && ref($copy[0]) eq "ARRAY";
86 for (@copy) { s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg; }
87 $self->query(@copy ? join('+', @copy) : undef);
88 }
89 return if !defined($old) || !defined(wantarray);
90 return if $old =~ /=/; # not keywords, but a form
91 map { uri_unescape($_) } split(/\+/, $old, -1);
92}
93
94# Some URI::URL compatibility stuff
95sub equery { goto &query }
96
9712µs1;
 
# spent 5.36ms within URI::_query::CORE:match which was called 4004 times, avg 1µs/call: # 4004 times (5.36ms+0s) by URI::_query::query at line 14, avg 1µs/call
sub URI::_query::CORE:match; # opcode
# spent 1.48ms within URI::_query::CORE:sort which was called 2002 times, avg 738ns/call: # 2002 times (1.48ms+0s) by URI::_query::query_form at line 43, avg 738ns/call
sub URI::_query::CORE:sort; # opcode