← 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/_query.pm
StatementsExecuted 60 statements in 883µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21138µs82µsURI::_query::::query_formURI::_query::query_form
42134µs44µsURI::_query::::queryURI::_query::query
11112µs28µsURI::_query::::BEGIN@3URI::_query::BEGIN@3
41110µs10µsURI::_query::::CORE:matchURI::_query::CORE:match (opcode)
1118µs35µsURI::_query::::BEGIN@5URI::_query::BEGIN@5
1114µs4µsURI::_query::::BEGIN@4URI::_query::BEGIN@4
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
3228µs243µs
# spent 28µs (12+15) within URI::_query::BEGIN@3 which was called: # once (12µs+15µs) by URI::implementor at line 3
use strict;
# spent 28µs making 1 call to URI::_query::BEGIN@3 # spent 15µs making 1 call to strict::import
4226µs14µs
# spent 4µs within URI::_query::BEGIN@4 which was called: # once (4µs+0s) by URI::implementor at line 4
use URI ();
# spent 4µs making 1 call to URI::_query::BEGIN@4
52736µs262µs
# spent 35µs (8+27) within URI::_query::BEGIN@5 which was called: # once (8µs+27µs) by URI::implementor at line 5
use URI::Escape qw(uri_unescape);
# spent 35µs making 1 call to URI::_query::BEGIN@5 # spent 27µs making 1 call to Exporter::import
6
7sub query
8
# spent 44µs (34+10) within URI::_query::query which was called 4 times, avg 11µs/call: # 2 times (20µs+6µs) by URI::_query::query_form at line 28, avg 13µs/call # 2 times (14µs+4µs) by URI::_query::query_form at line 64, avg 9µs/call
{
941µs my $self = shift;
10427µs410µs $$self =~ m,^([^?\#]*)(?:\?([^\#]*))?(.*)$,s or die;
# spent 10µs making 4 calls to URI::_query::CORE:match, avg 2µs/call
11
1242µs if (@_) {
132600ns my $q = shift;
1422µs $$self = $1;
152800ns if (defined $q) {
16 $q =~ s/([^$URI::uric])/ URI::Escape::escape_char($1)/ego;
17 utf8::downgrade($q);
18 $$self .= "?$q";
19 }
2022µs $$self .= $3;
21 }
22413µs $2;
23}
24
25# Handle ...?foo=bar&bar=foo type of query
26
# spent 82µs (38+44) within URI::_query::query_form which was called 2 times, avg 41µs/call: # 2 times (38µs+44µs) by Search::Elasticsearch::Role::Cxn::HTTP::build_uri at line 94 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm, avg 41µs/call
sub query_form {
2721µs my $self = shift;
2827µs226µs my $old = $self->query;
# spent 26µs making 2 calls to URI::_query::query, avg 13µs/call
2922µs if (@_) {
30 # Try to set query string
312200ns my $delim;
322800ns my $r = $_[0];
3324µs if (ref($r) eq "ARRAY") {
34 $delim = $_[1];
35 @_ = @$r;
36 }
37 elsif (ref($r) eq "HASH") {
382600ns $delim = $_[1];
3922µs @_ = %$r;
40 }
4122µs $delim = pop if @_ % 2;
42
432500ns my @query;
4423µs while (my($key,$vals) = splice(@_, 0, 2)) {
45 $key = '' unless defined $key;
46 $key =~ s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg;
47 $key =~ s/ /+/g;
48 $vals = [ref($vals) eq "ARRAY" ? @$vals : $vals];
49 for my $val (@$vals) {
50 $val = '' unless defined $val;
51 $val =~ s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg;
52 $val =~ s/ /+/g;
53 push(@query, "$key=$val");
54 }
55 }
5622µs if (@query) {
57 unless ($delim) {
58 $delim = $1 if $old && $old =~ /([&;])/;
59 $delim ||= $URI::DEFAULT_QUERY_FORM_DELIMITER || "&";
60 }
61 $self->query(join($delim, @query));
62 }
63 else {
6424µs218µs $self->query(undef);
# spent 18µs making 2 calls to URI::_query::query, avg 9µs/call
65 }
66 }
67210µs return if !defined($old) || !length($old) || !defined(wantarray);
68 return unless $old =~ /=/; # not a form
69 map { s/\+/ /g; uri_unescape($_) }
70 map { /=/ ? split(/=/, $_, 2) : ($_ => '')} split(/[&;]/, $old);
71}
72
73# Handle ...?dog+bones type of query
74sub query_keywords
75{
76 my $self = shift;
77 my $old = $self->query;
78 if (@_) {
79 # Try to set query string
80 my @copy = @_;
81 @copy = @{$copy[0]} if @copy == 1 && ref($copy[0]) eq "ARRAY";
82 for (@copy) { s/([;\/?:@&=+,\$\[\]%])/ URI::Escape::escape_char($1)/eg; }
83 $self->query(@copy ? join('+', @copy) : undef);
84 }
85 return if !defined($old) || !defined(wantarray);
86 return if $old =~ /=/; # not keywords, but a form
87 map { uri_unescape($_) } split(/\+/, $old, -1);
88}
89
90# Some URI::URL compatibility stuff
9112µs*equery = \&query;
92
9314µs1;
 
# spent 10µs within URI::_query::CORE:match which was called 4 times, avg 2µs/call: # 4 times (10µs+0s) by URI::_query::query at line 10, avg 2µs/call
sub URI::_query::CORE:match; # opcode