← 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/opt/flows/lib/lib/perl5/Search/Elasticsearch/Role/Cxn/HTTP.pm
StatementsExecuted 84 statements in 1.44ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11181µs7.94msSearch::Elasticsearch::Role::Cxn::HTTP::::BUILDARGSSearch::Elasticsearch::Role::Cxn::HTTP::BUILDARGS
21160µs271µsSearch::Elasticsearch::Role::Cxn::HTTP::::build_uriSearch::Elasticsearch::Role::Cxn::HTTP::build_uri
21135µs52µsSearch::Elasticsearch::Role::Cxn::HTTP::::__ANON__[:136]Search::Elasticsearch::Role::Cxn::HTTP::__ANON__[:136]
44334µs43µsSearch::Elasticsearch::Role::Cxn::HTTP::::stringifySearch::Elasticsearch::Role::Cxn::HTTP::stringify
21120µs20µsSearch::Elasticsearch::Role::Cxn::HTTP::::__ANON__[:122]Search::Elasticsearch::Role::Cxn::HTTP::__ANON__[:122]
11117µs341µsSearch::Elasticsearch::Role::Cxn::HTTP::::BEGIN@3Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@3
11112µs23µsSearch::Elasticsearch::Role::Cxn::HTTP::::BEGIN@146Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@146
11110µs227µsSearch::Elasticsearch::Role::Cxn::HTTP::::BEGIN@7Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@7
1118µs210µsSearch::Elasticsearch::Role::Cxn::HTTP::::BEGIN@6Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@6
1117µs44µsSearch::Elasticsearch::Role::Cxn::HTTP::::__ANON__[:3]Search::Elasticsearch::Role::Cxn::HTTP::__ANON__[:3]
2117µs7µsSearch::Elasticsearch::Role::Cxn::HTTP::::__ANON__[:112]Search::Elasticsearch::Role::Cxn::HTTP::__ANON__[:112]
1115µs5µsSearch::Elasticsearch::Role::Cxn::HTTP::::BEGIN@5Search::Elasticsearch::Role::Cxn::HTTP::BEGIN@5
2214µs4µsSearch::Elasticsearch::Role::Cxn::HTTP::::CORE:substSearch::Elasticsearch::Role::Cxn::HTTP::CORE:subst (opcode)
1112µs2µsSearch::Elasticsearch::Role::Cxn::HTTP::::default_hostSearch::Elasticsearch::Role::Cxn::HTTP::default_host
1111µs1µsSearch::Elasticsearch::Role::Cxn::HTTP::::CORE:matchSearch::Elasticsearch::Role::Cxn::HTTP::CORE:match (opcode)
111700ns700nsSearch::Elasticsearch::Role::Cxn::HTTP::::_pidSearch::Elasticsearch::Role::Cxn::HTTP::_pid (xsub)
111700ns700nsSearch::Elasticsearch::Role::Cxn::HTTP::::default_headersSearch::Elasticsearch::Role::Cxn::HTTP::default_headers (xsub)
111600ns600nsSearch::Elasticsearch::Role::Cxn::HTTP::::is_httpsSearch::Elasticsearch::Role::Cxn::HTTP::is_https (xsub)
0000s0sSearch::Elasticsearch::Role::Cxn::HTTP::::inflateSearch::Elasticsearch::Role::Cxn::HTTP::inflate
0000s0sSearch::Elasticsearch::Role::Cxn::HTTP::::protocolSearch::Elasticsearch::Role::Cxn::HTTP::protocol
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Search::Elasticsearch::Role::Cxn::HTTP;
21500ns$Search::Elasticsearch::Role::Cxn::HTTP::VERSION = '2.02';
3445µs3702µ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
use Moo::Role;
# 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
5230µs15µ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
use URI();
6237µs2413µ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
use Search::Elasticsearch::Util qw(parse_params throw);
72957µs2445µ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
use namespace::clean;
# 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
912µs1156µshas 'scheme' => ( is => 'ro' );
# spent 156µs making 1 call to Moo::Role::has
1011µs1113µshas 'is_https' => ( is => 'ro' );
# spent 113µs making 1 call to Moo::Role::has
1111µs1123µshas 'userinfo' => ( is => 'ro' );
# spent 123µs making 1 call to Moo::Role::has
1211µs1110µshas 'max_content_length' => ( is => 'ro' );
# spent 110µs making 1 call to Moo::Role::has
1311µs1114µshas 'default_headers' => ( is => 'ro' );
# spent 114µs making 1 call to Moo::Role::has
1411µs1210µshas 'ssl_options' => ( is => 'ro', predicate => 'has_ssl_options' );
# spent 210µs making 1 call to Moo::Role::has
1511µs1236µshas 'handle' => ( is => 'lazy', clearer => 1 );
# spent 236µs making 1 call to Moo::Role::has
1612µs1126µshas '_pid' => ( is => 'rw', default => $$ );
# spent 126µs making 1 call to Moo::Role::has
17
18#===================================
19sub protocol {'http'}
2014µ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
sub default_host {'http://localhost:9200'}
21435µs510µ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
sub stringify { shift->uri . '' }
# 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]
sub BUILDARGS {
26#===================================
2712µs16µs my ( $class, $params ) = parse_params(@_);
# spent 6µs making 1 call to Search::Elasticsearch::Util::parse_params
28
291700ns my $node = $params->{node}
30 || { host => 'localhost', port => '9200' };
31
321900ns unless ( ref $node eq 'HASH' ) {
3317µs11µs unless ( $node =~ m{^http(s)?://} ) {
34 $node = ( $params->{use_https} ? 'https://' : 'http://' ) . $node;
35 }
361300ns if ( $params->{port} && $node !~ m{//[^/]+:\d+} ) {
37 $node =~ s{(//[^/]+)}{$1:$params->{port}};
38 }
3912µs17.41ms my $uri = URI->new($node);
# spent 7.41ms making 1 call to URI::new
40130µs5312µ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
4911µs my $host = $node->{host} || 'localhost';
501700ns my $userinfo = $node->{userinfo} || $params->{userinfo} || '';
511300ns my $scheme
52 = $node->{scheme} || ( $params->{use_https} ? 'https' : 'http' );
531300ns my $port
54 = $node->{port}
55 || $params->{port}
56 || ( $scheme eq 'http' ? 80 : 443 );
571800ns my $path = $node->{path} || $params->{path_prefix} || '';
5819µs13µs $path =~ s{^/?}{/}g;
5914µs11µs $path =~ s{/+$}{};
60
6112µs my %default_headers = %{ $params->{default_headers} || {} };
62
631200ns 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
701300ns if ( $params->{deflate} ) {
71 $default_headers{'Accept-Encoding'} = "deflate";
72 }
73
741600ns $params->{scheme} = $scheme;
751700ns $params->{is_https} = $scheme eq 'https';
761400ns $params->{host} = $host;
771800ns $params->{port} = $port;
781400ns $params->{path} = $path;
791300ns $params->{userinfo} = $userinfo;
8013µs1125µs $params->{uri} = URI->new("$scheme://$host:$port$path");
# spent 125µs making 1 call to URI::new
811500ns $params->{default_headers} = \%default_headers;
82
8315µ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
sub build_uri {
89#===================================
9021µs my ( $self, $params ) = @_;
91213µs310µ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
9229µs4118µs $uri->path( $uri->path . $params->{path} );
# spent 118µs making 4 calls to URI::_generic::path, avg 29µs/call
93213µs1900ns my %qs = ( %{ $self->default_qs_params }, %{ $params->{qs} || {} } );
94210µs282µs $uri->query_form( \%qs );
# spent 82µs making 2 calls to URI::_query::query_form, avg 41µs/call
9527µ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
before 'perform_request' => sub {
100#===================================
10121µs my ( $self, $params ) = @_;
102210µ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 );
11214µs11.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
before 'handle' => sub {
116#===================================
11721µs my $self = shift;
118224µs1700ns if ( $$ != $self->_pid ) {
# spent 700ns making 1 call to Search::Elasticsearch::Role::Cxn::HTTP::_pid
119 $self->clear_handle;
120 $self->_pid($$);
121 }
12213µs16µ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
around 'process_response' => sub {
126#===================================
12724µs my ( $orig, $self, $params, $code, $msg, $body, $headers ) = @_;
128
12922µs if ( my $encoding = $headers->{'content-encoding'} ) {
130 $body = $self->inflate($body)
131 if $encoding eq 'deflate';
132 }
133
134212µs my ($mime_type) = split /\s*;\s*/, ( $headers->{'content-type'} || '' );
135218µs217µ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
13613µs16µs};
# spent 6µs making 1 call to Moo::Role::around
137
138#===================================
139sub inflate {
140#===================================
141 my $self = shift;
142 my $content = shift;
143
144 my $output;
145 require IO::Uncompress::Inflate;
146286µs234µ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
no warnings 'once';
# 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
155111µs1;
156
157# ABSTRACT: Provides common functionality to HTTP Cxn implementations
158
159118µs1376µs__END__
 
# 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:match; # opcode
# spent 4µs within Search::Elasticsearch::Role::Cxn::HTTP::CORE:subst which was called 2 times, avg 2µs/call: # once (3µs+0s) by Search::Elasticsearch::Role::Cxn::HTTP::BUILDARGS at line 58 # once (1µs+0s) by Search::Elasticsearch::Role::Cxn::HTTP::BUILDARGS at line 59
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
sub Search::Elasticsearch::Role::Cxn::HTTP::_pid; # xsub
# 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
sub Search::Elasticsearch::Role::Cxn::HTTP::default_headers; # xsub
# 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
sub Search::Elasticsearch::Role::Cxn::HTTP::is_https; # xsub