Filename | /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm |
Statements | Executed 84 statements in 1.44ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 81µs | 7.94ms | BUILDARGS | Search::Elasticsearch::Role::Cxn::HTTP::
2 | 1 | 1 | 60µs | 271µs | build_uri | Search::Elasticsearch::Role::Cxn::HTTP::
2 | 1 | 1 | 35µs | 52µs | __ANON__[:136] | Search::Elasticsearch::Role::Cxn::HTTP::
4 | 4 | 3 | 34µs | 43µs | stringify | Search::Elasticsearch::Role::Cxn::HTTP::
2 | 1 | 1 | 20µs | 20µs | __ANON__[:122] | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 17µs | 341µs | BEGIN@3 | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 12µs | 23µs | BEGIN@146 | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 10µs | 227µs | BEGIN@7 | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 8µs | 210µs | BEGIN@6 | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 7µs | 44µs | __ANON__[:3] | Search::Elasticsearch::Role::Cxn::HTTP::
2 | 1 | 1 | 7µs | 7µs | __ANON__[:112] | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 5µs | 5µs | BEGIN@5 | Search::Elasticsearch::Role::Cxn::HTTP::
2 | 2 | 1 | 4µs | 4µs | CORE:subst (opcode) | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 2µs | 2µs | default_host | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 1µs | 1µs | CORE:match (opcode) | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 700ns | 700ns | _pid (xsub) | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 700ns | 700ns | default_headers (xsub) | Search::Elasticsearch::Role::Cxn::HTTP::
1 | 1 | 1 | 600ns | 600ns | is_https (xsub) | Search::Elasticsearch::Role::Cxn::HTTP::
0 | 0 | 0 | 0s | 0s | inflate | Search::Elasticsearch::Role::Cxn::HTTP::
0 | 0 | 0 | 0s | 0s | protocol | Search::Elasticsearch::Role::Cxn::HTTP::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Search::Elasticsearch::Role::Cxn::HTTP; | ||||
2 | 1 | 500ns | $Search::Elasticsearch::Role::Cxn::HTTP::VERSION = '2.02'; | ||
3 | 4 | 45µs | 3 | 702µs | # spent 44µs (7+37) within Search::Elasticsearch::Role::Cxn::HTTP::__ANON__[/opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm:3] which was called:
# once (7µs+37µs) by import::into at line 34 of Import/Into.pm
# spent 341µs (17+324) within Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@3 which was called:
# once (17µs+324µs) by Module::Runtime::require_module at line 3 # spent 341µs making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@3
# spent 324µs making 1 call to Moo::Role::import
# spent 37µs making 1 call to strictures::import |
4 | |||||
5 | 2 | 30µs | 1 | 5µs | # spent 5µs within Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@5 which was called:
# once (5µs+0s) by Module::Runtime::require_module at line 5 # spent 5µs making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@5 |
6 | 2 | 37µs | 2 | 413µs | # spent 210µs (8+202) within Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@6 which was called:
# once (8µs+202µs) by Module::Runtime::require_module at line 6 # spent 210µs making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@6
# spent 202µs making 1 call to Sub::Exporter::__ANON__[/opt/flows/lib/lib/perl5/Sub/Exporter.pm:337] |
7 | 2 | 957µs | 2 | 445µs | # spent 227µs (10+218) within Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@7 which was called:
# once (10µs+218µs) by Module::Runtime::require_module at line 7 # spent 227µs making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@7
# spent 218µs making 1 call to namespace::clean::import |
8 | |||||
9 | 1 | 2µs | 1 | 156µs | has 'scheme' => ( is => 'ro' ); # spent 156µs making 1 call to Moo::Role::has |
10 | 1 | 1µs | 1 | 113µs | has 'is_https' => ( is => 'ro' ); # spent 113µs making 1 call to Moo::Role::has |
11 | 1 | 1µs | 1 | 123µs | has 'userinfo' => ( is => 'ro' ); # spent 123µs making 1 call to Moo::Role::has |
12 | 1 | 1µs | 1 | 110µs | has 'max_content_length' => ( is => 'ro' ); # spent 110µs making 1 call to Moo::Role::has |
13 | 1 | 1µs | 1 | 114µs | has 'default_headers' => ( is => 'ro' ); # spent 114µs making 1 call to Moo::Role::has |
14 | 1 | 1µs | 1 | 210µs | has 'ssl_options' => ( is => 'ro', predicate => 'has_ssl_options' ); # spent 210µs making 1 call to Moo::Role::has |
15 | 1 | 1µs | 1 | 236µs | has 'handle' => ( is => 'lazy', clearer => 1 ); # spent 236µs making 1 call to Moo::Role::has |
16 | 1 | 2µs | 1 | 126µs | has '_pid' => ( is => 'rw', default => $$ ); # spent 126µs making 1 call to Moo::Role::has |
17 | |||||
18 | #=================================== | ||||
19 | sub protocol {'http'} | ||||
20 | 1 | 4µs | # spent 2µs within Search::Elasticsearch::Role::Cxn::HTTP::default_host which was called:
# once (2µs+0s) by Search::Elasticsearch::Cxn::Factory::BUILDARGS at line 29 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Cxn/Factory.pm | ||
21 | 4 | 35µs | 5 | 10µs | # spent 43µs (34+10) within Search::Elasticsearch::Role::Cxn::HTTP::stringify which was called 4 times, avg 11µs/call:
# once (11µs+4µs) by Search::Elasticsearch::Role::Cxn::try {...} at line 88 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn.pm
# once (11µs+2µs) by Search::Elasticsearch::Role::CxnPool::set_cxns at line 56 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/CxnPool.pm
# once (6µs+2µs) by Search::Elasticsearch::Role::Cxn::pings_ok at line 80 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn.pm
# once (5µs+2µs) by Search::Elasticsearch::Role::CxnPool::Static::schedule_check at line 24 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/CxnPool/Static.pm # spent 9µs making 4 calls to URI::__ANON__[URI.pm:24], avg 2µs/call
# spent 600ns making 1 call to Search::Elasticsearch::Role::Cxn::uri |
22 | #=================================== | ||||
23 | |||||
24 | #=================================== | ||||
25 | # spent 7.94ms (81µs+7.86) within Search::Elasticsearch::Role::Cxn::HTTP::BUILDARGS which was called:
# once (81µs+7.86ms) by Search::Elasticsearch::Cxn::HTTPTiny::new at line 24 of (eval 87)[Sub/Quote.pm:5] | ||||
26 | #=================================== | ||||
27 | 1 | 2µs | 1 | 6µs | my ( $class, $params ) = parse_params(@_); # spent 6µs making 1 call to Search::Elasticsearch::Util::parse_params |
28 | |||||
29 | 1 | 700ns | my $node = $params->{node} | ||
30 | || { host => 'localhost', port => '9200' }; | ||||
31 | |||||
32 | 1 | 900ns | unless ( ref $node eq 'HASH' ) { | ||
33 | 1 | 7µs | 1 | 1µs | unless ( $node =~ m{^http(s)?://} ) { # spent 1µs making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::CORE:match |
34 | $node = ( $params->{use_https} ? 'https://' : 'http://' ) . $node; | ||||
35 | } | ||||
36 | 1 | 300ns | if ( $params->{port} && $node !~ m{//[^/]+:\d+} ) { | ||
37 | $node =~ s{(//[^/]+)}{$1:$params->{port}}; | ||||
38 | } | ||||
39 | 1 | 2µs | 1 | 7.41ms | my $uri = URI->new($node); # spent 7.41ms making 1 call to URI::new |
40 | 1 | 30µs | 5 | 312µs | $node = { # spent 134µs making 1 call to URI::_server::host
# spent 126µs making 1 call to URI::scheme
# spent 26µs making 1 call to URI::_server::port
# spent 19µs making 1 call to URI::_server::userinfo
# spent 8µs making 1 call to URI::_generic::path |
41 | scheme => $uri->scheme, | ||||
42 | host => $uri->host, | ||||
43 | port => $uri->port, | ||||
44 | path => $uri->path, | ||||
45 | userinfo => $uri->userinfo | ||||
46 | }; | ||||
47 | } | ||||
48 | |||||
49 | 1 | 1µs | my $host = $node->{host} || 'localhost'; | ||
50 | 1 | 700ns | my $userinfo = $node->{userinfo} || $params->{userinfo} || ''; | ||
51 | 1 | 300ns | my $scheme | ||
52 | = $node->{scheme} || ( $params->{use_https} ? 'https' : 'http' ); | ||||
53 | 1 | 300ns | my $port | ||
54 | = $node->{port} | ||||
55 | || $params->{port} | ||||
56 | || ( $scheme eq 'http' ? 80 : 443 ); | ||||
57 | 1 | 800ns | my $path = $node->{path} || $params->{path_prefix} || ''; | ||
58 | 1 | 9µs | 1 | 3µs | $path =~ s{^/?}{/}g; # spent 3µs making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::CORE:subst |
59 | 1 | 4µs | 1 | 1µs | $path =~ s{/+$}{}; # spent 1µs making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::CORE:subst |
60 | |||||
61 | 1 | 2µs | my %default_headers = %{ $params->{default_headers} || {} }; | ||
62 | |||||
63 | 1 | 200ns | if ($userinfo) { | ||
64 | require MIME::Base64; | ||||
65 | my $auth = MIME::Base64::encode_base64($userinfo); | ||||
66 | chomp $auth; | ||||
67 | $default_headers{Authorization} = "Basic $auth"; | ||||
68 | } | ||||
69 | |||||
70 | 1 | 300ns | if ( $params->{deflate} ) { | ||
71 | $default_headers{'Accept-Encoding'} = "deflate"; | ||||
72 | } | ||||
73 | |||||
74 | 1 | 600ns | $params->{scheme} = $scheme; | ||
75 | 1 | 700ns | $params->{is_https} = $scheme eq 'https'; | ||
76 | 1 | 400ns | $params->{host} = $host; | ||
77 | 1 | 800ns | $params->{port} = $port; | ||
78 | 1 | 400ns | $params->{path} = $path; | ||
79 | 1 | 300ns | $params->{userinfo} = $userinfo; | ||
80 | 1 | 3µs | 1 | 125µs | $params->{uri} = URI->new("$scheme://$host:$port$path"); # spent 125µs making 1 call to URI::new |
81 | 1 | 500ns | $params->{default_headers} = \%default_headers; | ||
82 | |||||
83 | 1 | 5µs | return $params; | ||
84 | |||||
85 | } | ||||
86 | |||||
87 | #=================================== | ||||
88 | # spent 271µs (60+211) within Search::Elasticsearch::Role::Cxn::HTTP::build_uri which was called 2 times, avg 136µs/call:
# 2 times (60µs+211µs) by Search::Elasticsearch::Cxn::HTTPTiny::perform_request at line 22 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Cxn/HTTPTiny.pm, avg 136µs/call | ||||
89 | #=================================== | ||||
90 | 2 | 1µs | my ( $self, $params ) = @_; | ||
91 | 2 | 13µs | 3 | 10µs | my $uri = $self->uri->clone; # spent 9µs making 2 calls to URI::clone, avg 5µs/call
# spent 700ns making 1 call to Search::Elasticsearch::Role::Cxn::uri |
92 | 2 | 9µs | 4 | 118µs | $uri->path( $uri->path . $params->{path} ); # spent 118µs making 4 calls to URI::_generic::path, avg 29µs/call |
93 | 2 | 13µs | 1 | 900ns | my %qs = ( %{ $self->default_qs_params }, %{ $params->{qs} || {} } ); # spent 900ns making 1 call to Search::Elasticsearch::Role::Cxn::default_qs_params |
94 | 2 | 10µs | 2 | 82µs | $uri->query_form( \%qs ); # spent 82µs making 2 calls to URI::_query::query_form, avg 41µs/call |
95 | 2 | 7µs | return $uri; | ||
96 | } | ||||
97 | |||||
98 | #=================================== | ||||
99 | # spent 7µs within Search::Elasticsearch::Role::Cxn::HTTP::__ANON__[/opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm:112] which was called 2 times, avg 3µs/call:
# 2 times (7µs+0s) by Search::Elasticsearch::Cxn::HTTPTiny::perform_request at line 4 of (eval 70)[Class/Method/Modifiers.pm:152], avg 3µs/call | ||||
100 | #=================================== | ||||
101 | 2 | 1µs | my ( $self, $params ) = @_; | ||
102 | 2 | 10µs | return unless defined $params->{data}; | ||
103 | |||||
104 | my $max = $self->max_content_length | ||||
105 | or return; | ||||
106 | |||||
107 | return if length( $params->{data} ) < $max; | ||||
108 | |||||
109 | $self->logger->throw_error( 'ContentLength', | ||||
110 | "Body is longer than max_content_length ($max)", | ||||
111 | ); | ||||
112 | 1 | 4µs | 1 | 1.64ms | }; # spent 1.64ms making 1 call to Moo::Role::before |
113 | |||||
114 | #=================================== | ||||
115 | # spent 20µs (20+700ns) within Search::Elasticsearch::Role::Cxn::HTTP::__ANON__[/opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm:122] which was called 2 times, avg 10µs/call:
# 2 times (20µs+700ns) by Search::Elasticsearch::Cxn::HTTPTiny::handle at line 4 of (eval 73)[Class/Method/Modifiers.pm:152], avg 10µs/call | ||||
116 | #=================================== | ||||
117 | 2 | 1µs | my $self = shift; | ||
118 | 2 | 24µs | 1 | 700ns | if ( $$ != $self->_pid ) { # spent 700ns making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::_pid |
119 | $self->clear_handle; | ||||
120 | $self->_pid($$); | ||||
121 | } | ||||
122 | 1 | 3µs | 1 | 6µs | }; # spent 6µs making 1 call to Moo::Role::before |
123 | |||||
124 | #=================================== | ||||
125 | # spent 52µs (35+17) within Search::Elasticsearch::Role::Cxn::HTTP::__ANON__[/opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm:136] which was called 2 times, avg 26µs/call:
# 2 times (35µs+17µs) by Search::Elasticsearch::Cxn::HTTPTiny::__ANON__[(eval 75)[/usr/share/perl5/Class/Method/Modifiers.pm:93]:1] at line 1 of (eval 75)[Class/Method/Modifiers.pm:93], avg 26µs/call | ||||
126 | #=================================== | ||||
127 | 2 | 4µs | my ( $orig, $self, $params, $code, $msg, $body, $headers ) = @_; | ||
128 | |||||
129 | 2 | 2µs | if ( my $encoding = $headers->{'content-encoding'} ) { | ||
130 | $body = $self->inflate($body) | ||||
131 | if $encoding eq 'deflate'; | ||||
132 | } | ||||
133 | |||||
134 | 2 | 12µs | my ($mime_type) = split /\s*;\s*/, ( $headers->{'content-type'} || '' ); | ||
135 | 2 | 18µs | 2 | 17µs | $orig->( $self, $params, $code, $msg, $body, $mime_type ); # spent 17µs making 2 calls to Search::Elasticsearch::Role::Cxn::process_response, avg 8µs/call |
136 | 1 | 3µs | 1 | 6µs | }; # spent 6µs making 1 call to Moo::Role::around |
137 | |||||
138 | #=================================== | ||||
139 | sub inflate { | ||||
140 | #=================================== | ||||
141 | my $self = shift; | ||||
142 | my $content = shift; | ||||
143 | |||||
144 | my $output; | ||||
145 | require IO::Uncompress::Inflate; | ||||
146 | 2 | 86µs | 2 | 34µs | # spent 23µs (12+11) within Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@146 which was called:
# once (12µs+11µs) by Module::Runtime::require_module at line 146 # spent 23µs making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@146
# spent 11µs making 1 call to warnings::unimport |
147 | |||||
148 | IO::Uncompress::Inflate::inflate( \$content, \$output, Transparent => 0 ) | ||||
149 | or throw( 'Request', | ||||
150 | "Couldn't inflate response: $IO::Uncompress::Inflate::InflateError" ); | ||||
151 | |||||
152 | return $output; | ||||
153 | } | ||||
154 | |||||
155 | 1 | 11µs | 1; | ||
156 | |||||
157 | # ABSTRACT: Provides common functionality to HTTP Cxn implementations | ||||
158 | |||||
159 | 1 | 18µs | 1 | 376µs | __END__ # spent 376µs making 1 call to B::Hooks::EndOfScope::XS::__ANON__[/opt/flows/lib/lib/perl5/B/Hooks/EndOfScope/XS.pm:17] |
# spent 1µs within Search::Elasticsearch::Role::Cxn::HTTP::CORE:match which was called:
# once (1µs+0s) by Search::Elasticsearch::Role::Cxn::HTTP::BUILDARGS at line 33 | |||||
sub Search::Elasticsearch::Role::Cxn::HTTP::CORE:subst; # opcode | |||||
# spent 700ns within Search::Elasticsearch::Role::Cxn::HTTP::_pid which was called:
# once (700ns+0s) by Search::Elasticsearch::Role::Cxn::HTTP::__ANON__[/opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm:122] at line 118 | |||||
# spent 700ns within Search::Elasticsearch::Role::Cxn::HTTP::default_headers which was called:
# once (700ns+0s) by Search::Elasticsearch::Cxn::HTTPTiny::_build_handle at line 61 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Cxn/HTTPTiny.pm | |||||
# spent 600ns within Search::Elasticsearch::Role::Cxn::HTTP::is_https which was called:
# once (600ns+0s) by Search::Elasticsearch::Cxn::HTTPTiny::_build_handle at line 62 of /opt/flows/lib/lib/perl5/Search/Elasticsearch/Cxn/HTTPTiny.pm |