← 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/Search/Elasticsearch/Role/Logger.pm
StatementsExecuted 4026 statements in 10.4ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
10011124.2ms84.5msSearch::Elasticsearch::Role::Logger::::trace_responseSearch::Elasticsearch::Role::Logger::trace_response
1001116.92ms127msSearch::Elasticsearch::Role::Logger::::trace_requestSearch::Elasticsearch::Role::Logger::trace_request
1111.11ms1.80msSearch::Elasticsearch::Role::Logger::::BEGIN@5Search::Elasticsearch::Role::Logger::BEGIN@5
1118µs477µsSearch::Elasticsearch::Role::Logger::::BEGIN@3Search::Elasticsearch::Role::Logger::BEGIN@3
1116µs30µsSearch::Elasticsearch::Role::Logger::::BEGIN@6Search::Elasticsearch::Role::Logger::BEGIN@6
1115µs85µsSearch::Elasticsearch::Role::Logger::::BEGIN@7Search::Elasticsearch::Role::Logger::BEGIN@7
1114µs119µsSearch::Elasticsearch::Role::Logger::::BEGIN@8Search::Elasticsearch::Role::Logger::BEGIN@8
0000s0sSearch::Elasticsearch::Role::Logger::::deprecationSearch::Elasticsearch::Role::Logger::deprecation
0000s0sSearch::Elasticsearch::Role::Logger::::throw_criticalSearch::Elasticsearch::Role::Logger::throw_critical
0000s0sSearch::Elasticsearch::Role::Logger::::throw_errorSearch::Elasticsearch::Role::Logger::throw_error
0000s0sSearch::Elasticsearch::Role::Logger::::trace_commentSearch::Elasticsearch::Role::Logger::trace_comment
0000s0sSearch::Elasticsearch::Role::Logger::::trace_errorSearch::Elasticsearch::Role::Logger::trace_error
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::Logger;
21300ns$Search::Elasticsearch::Role::Logger::VERSION = '5.01';
3219µs2945µs
# spent 477µs (8+469) within Search::Elasticsearch::Role::Logger::BEGIN@3 which was called: # once (8µs+469µs) by Module::Runtime::require_module at line 3
use Moo::Role;
# spent 477µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@3 # spent 469µs making 1 call to Moo::Role::import
4
5263µs11.80ms
# spent 1.80ms (1.11+690µs) within Search::Elasticsearch::Role::Logger::BEGIN@5 which was called: # once (1.11ms+690µs) by Module::Runtime::require_module at line 5
use URI();
# spent 1.80ms making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@5
6218µs254µs
# spent 30µs (6+24) within Search::Elasticsearch::Role::Logger::BEGIN@6 which was called: # once (6µs+24µs) by Module::Runtime::require_module at line 6
use Try::Tiny;
# spent 30µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@6 # spent 24µs making 1 call to Exporter::import
7218µs2165µs
# spent 85µs (5+80) within Search::Elasticsearch::Role::Logger::BEGIN@7 which was called: # once (5µs+80µs) by Module::Runtime::require_module at line 7
use Search::Elasticsearch::Util qw(new_error);
# spent 85µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@7 # spent 80µs making 1 call to Sub::Exporter::__ANON__[Sub/Exporter.pm:337]
82348µs2234µs
# spent 119µs (4+115) within Search::Elasticsearch::Role::Logger::BEGIN@8 which was called: # once (4µs+115µs) by Module::Runtime::require_module at line 8
use namespace::clean;
# spent 119µs making 1 call to Search::Elasticsearch::Role::Logger::BEGIN@8 # spent 115µs making 1 call to namespace::clean::import
9
101900ns191µshas 'serializer' => ( is => 'ro', required => 1 );
# spent 91µs making 1 call to Moo::Role::has
111700ns152µshas 'log_as' => ( is => 'ro', default => 'elasticsearch.event' );
# spent 52µs making 1 call to Moo::Role::has
121600ns146µshas 'trace_as' => ( is => 'ro', default => 'elasticsearch.trace' );
# spent 46µs making 1 call to Moo::Role::has
131500ns145µshas 'deprecate_as' => ( is => 'ro', default => 'elasticsearch.deprecation' );
# spent 45µs making 1 call to Moo::Role::has
141400ns144µshas 'log_to' => ( is => 'ro' );
# spent 44µs making 1 call to Moo::Role::has
151300ns144µshas 'trace_to' => ( is => 'ro' );
# spent 44µs making 1 call to Moo::Role::has
161400ns144µshas 'deprecate_to' => ( is => 'ro' );
# spent 44µs making 1 call to Moo::Role::has
17
181900ns1372µshas 'trace_handle' => (
# spent 372µs making 1 call to Moo::Role::has
19 is => 'lazy',
20 handles => [qw( trace tracef is_trace)]
21);
22
2311µs1684µshas 'log_handle' => (
# spent 684µs making 1 call to Moo::Role::has
24 is => 'lazy',
25 handles => [ qw(
26 debug debugf is_debug
27 info infof is_info
28 warning warningf is_warning
29 error errorf is_error
30 critical criticalf is_critical
31 )
32 ]
33);
34
351600ns1117µshas 'deprecate_handle' => ( is => 'lazy' );
# spent 117µs making 1 call to Moo::Role::has
36
37#===================================
38sub throw_error {
39#===================================
40 my ( $self, $type, $msg, $vars ) = @_;
41 my $error = new_error( $type, $msg, $vars );
42 $self->error($error);
43 die $error;
44}
45
46#===================================
47sub throw_critical {
48#===================================
49 my ( $self, $type, $msg, $vars ) = @_;
50 my $error = new_error( $type, $msg, $vars );
51 $self->critical($error);
52 die $error;
53}
54
55#===================================
56
# spent 127ms (6.92+120) within Search::Elasticsearch::Role::Logger::trace_request which was called 1001 times, avg 127µs/call: # 1001 times (6.92ms+120ms) by Search::Elasticsearch::Transport::try {...} at line 27 of Search/Elasticsearch/Transport.pm, avg 127µs/call
sub trace_request {
57#===================================
581001545µs my ( $self, $cxn, $params ) = @_;
5910013.75ms10011.89ms return unless $self->is_trace;
# spent 1.89ms making 1001 calls to Search::Elasticsearch::Role::Logger::is_trace, avg 2µs/call
60
61 my $uri = URI->new( 'http://localhost:9200' . $params->{path} );
62 my %qs = ( %{ $params->{qs} }, pretty => 1 );
63 $uri->query_form( [ map { $_, $qs{$_} } sort keys %qs ] );
64
65 my $body
66 = $params->{serialize} eq 'std'
67 ? $self->serializer->encode_pretty( $params->{body} )
68 : $params->{data};
69
70 if ( defined $body ) {
71 $body =~ s/'/\\u0027/g;
72 $body = " -d '\n$body'\n";
73 }
74 else { $body = "\n" }
75
76 my $msg = sprintf(
77 "# Request to: %s\n" #
78 . "curl -X%s '%s'%s", #
79 $cxn->stringify,
80 $params->{method},
81 $uri,
82 $body
83 );
84
85 $self->trace($msg);
86}
87
88#===================================
89
# spent 84.5ms (24.2+60.4) within Search::Elasticsearch::Role::Logger::trace_response which was called 1001 times, avg 84µs/call: # 1001 times (24.2ms+60.4ms) by Search::Elasticsearch::Transport::try {...} at line 31 of Search/Elasticsearch/Transport.pm, avg 84µs/call
sub trace_response {
90#===================================
911001745µs my ( $self, $cxn, $code, $response, $took ) = @_;
9210014.83ms10013.46ms return unless $self->is_trace;
# spent 3.46ms making 1001 calls to Search::Elasticsearch::Role::Logger::is_trace, avg 3µs/call
93
94 my $body = $self->serializer->encode_pretty($response) || "\n";
95 $body =~ s/^/# /mg;
96
97 my $msg = sprintf(
98 "# Response: %s, Took: %d ms\n%s", #
99 $code, $took * 1000, $body
100 );
101
102 $self->trace($msg);
103}
104
105#===================================
106sub trace_error {
107#===================================
108 my ( $self, $cxn, $error ) = @_;
109 return unless $self->is_trace;
110
111 my $body
112 = $self->serializer->encode_pretty( $error->{vars}{body} || "\n" );
113 $body =~ s/^/# /mg;
114
115 my $msg
116 = sprintf( "# ERROR: %s %s\n%s", ref($error), $error->{text}, $body );
117
118 $self->trace($msg);
119}
120
121#===================================
122sub trace_comment {
123#===================================
124 my ( $self, $comment ) = @_;
125 return unless $self->is_trace;
126 $comment =~ s/^/# *** /mg;
127 chomp $comment;
128 $self->trace("$comment\n");
129}
130
131#===================================
132sub deprecation {
133#===================================
134 my $self = shift;
135 $self->deprecate_handle->warnf( "[DEPRECATION] %s. In request: %s", @_ );
136}
13719µs1;
138
139# ABSTRACT: Provides common functionality to Logger implementations
140
141110µs1198µs__END__