← 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/Log/Any/Adapter/Util.pm
StatementsExecuted 4082 statements in 20.1ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
20031114.3ms18.3msLog::Any::Adapter::Util::::require_dynamicLog::Any::Adapter::Util::require_dynamic
141114µs14µsLog::Any::Adapter::Util::::numeric_levelLog::Any::Adapter::Util::numeric_level
11113µs13µsLog::Any::Adapter::Util::::BEGIN@52Log::Any::Adapter::Util::BEGIN@52
11110µs88µsLog::Any::Adapter::Util::::BEGIN@28Log::Any::Adapter::Util::BEGIN@28
11110µs10µsLog::Any::::BEGIN@1.31 Log::Any::BEGIN@1.31
1118µs14µsLog::Any::Adapter::Util::::BEGIN@156Log::Any::Adapter::Util::BEGIN@156
1116µs22µsLog::Any::Adapter::Util::::BEGIN@10Log::Any::Adapter::Util::BEGIN@10
1116µs6µsLog::Any::Adapter::Util::::BEGIN@14Log::Any::Adapter::Util::BEGIN@14
1115µs6µsLog::Any::::BEGIN@2.32 Log::Any::BEGIN@2.32
1115µs36µsLog::Any::Adapter::Util::::BEGIN@11Log::Any::Adapter::Util::BEGIN@11
1115µs8µsLog::Any::::BEGIN@3.33 Log::Any::BEGIN@3.33
2223µs3µsLog::Any::Adapter::Util::::logging_and_detection_methodsLog::Any::Adapter::Util::logging_and_detection_methods
1112µs2µsLog::Any::Adapter::Util::::log_level_aliasesLog::Any::Adapter::Util::log_level_aliases
111800ns800nsLog::Any::Adapter::Util::::logging_methodsLog::Any::Adapter::Util::logging_methods
0000s0sLog::Any::Adapter::Util::::cmp_deeplyLog::Any::Adapter::Util::cmp_deeply
0000s0sLog::Any::Adapter::Util::::detection_aliasesLog::Any::Adapter::Util::detection_aliases
0000s0sLog::Any::Adapter::Util::::detection_methodsLog::Any::Adapter::Util::detection_methods
0000s0sLog::Any::Adapter::Util::::dump_one_lineLog::Any::Adapter::Util::dump_one_line
0000s0sLog::Any::Adapter::Util::::logging_aliasesLog::Any::Adapter::Util::logging_aliases
0000s0sLog::Any::Adapter::Util::::make_methodLog::Any::Adapter::Util::make_method
0000s0sLog::Any::Adapter::Util::::read_fileLog::Any::Adapter::Util::read_file
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1225µs110µs
# spent 10µs within Log::Any::BEGIN@1.31 which was called: # once (10µs+0s) by Log::Any::BEGIN@11 at line 1
use 5.008001;
# spent 10µs making 1 call to Log::Any::BEGIN@1.31
2212µs28µs
# spent 6µs (5+1) within Log::Any::BEGIN@2.32 which was called: # once (5µs+1µs) by Log::Any::BEGIN@11 at line 2
use strict;
# spent 6µs making 1 call to Log::Any::BEGIN@2.32 # spent 2µs making 1 call to strict::import
3230µs211µs
# spent 8µs (5+3) within Log::Any::BEGIN@3.33 which was called: # once (5µs+3µs) by Log::Any::BEGIN@11 at line 3
use warnings;
# spent 8µs making 1 call to Log::Any::BEGIN@3.33 # spent 3µs making 1 call to warnings::import
4
5package Log::Any::Adapter::Util;
6
7# ABSTRACT: Common utility functions for Log::Any
81200nsour $VERSION = '1.032';
9
10216µs237µs
# spent 22µs (6+16) within Log::Any::Adapter::Util::BEGIN@10 which was called: # once (6µs+16µs) by Log::Any::BEGIN@11 at line 10
use Data::Dumper;
# spent 22µs making 1 call to Log::Any::Adapter::Util::BEGIN@10 # spent 16µs making 1 call to Exporter::import
11231µs267µs
# spent 36µs (5+31) within Log::Any::Adapter::Util::BEGIN@11 which was called: # once (5µs+31µs) by Log::Any::BEGIN@11 at line 11
use base qw(Exporter);
# spent 36µs making 1 call to Log::Any::Adapter::Util::BEGIN@11 # spent 31µs making 1 call to base::import
12
131100nsmy %LOG_LEVELS;
14
# spent 6µs within Log::Any::Adapter::Util::BEGIN@14 which was called: # once (6µs+0s) by Log::Any::BEGIN@11 at line 26
BEGIN {
1517µs %LOG_LEVELS = (
16 EMERGENCY => 0,
17 ALERT => 1,
18 CRITICAL => 2,
19 ERROR => 3,
20 WARNING => 4,
21 NOTICE => 5,
22 INFO => 6,
23 DEBUG => 7,
24 TRACE => 8,
25 );
26115µs16µs}
# spent 6µs making 1 call to Log::Any::Adapter::Util::BEGIN@14
27
282230µs2166µs
# spent 88µs (10+78) within Log::Any::Adapter::Util::BEGIN@28 which was called: # once (10µs+78µs) by Log::Any::BEGIN@11 at line 28
use constant \%LOG_LEVELS;
# spent 88µs making 1 call to Log::Any::Adapter::Util::BEGIN@28 # spent 78µs making 1 call to constant::import
29
3011µsour @EXPORT_OK = qw(
31 cmp_deeply
32 detection_aliases
33 detection_methods
34 dump_one_line
35 log_level_aliases
36 logging_aliases
37 logging_and_detection_methods
38 logging_methods
39 make_method
40 numeric_level
41 read_file
42 require_dynamic
43);
44
4512µspush @EXPORT_OK, keys %LOG_LEVELS;
46
4712µsour %EXPORT_TAGS = ( 'levels' => [ keys %LOG_LEVELS ] );
48
491100nsmy ( %LOG_LEVEL_ALIASES, @logging_methods, @logging_aliases, @detection_methods,
50 @detection_aliases, @logging_and_detection_methods );
51
52
# spent 13µs within Log::Any::Adapter::Util::BEGIN@52 which was called: # once (13µs+0s) by Log::Any::BEGIN@11 at line 66
BEGIN {
5312µs %LOG_LEVEL_ALIASES = (
54 inform => 'info',
55 warn => 'warning',
56 err => 'error',
57 crit => 'critical',
58 fatal => 'critical'
59 );
601700ns @logging_methods =
61 qw(trace debug info notice warning error critical alert emergency);
6211µs @logging_aliases = keys(%LOG_LEVEL_ALIASES);
6313µs @detection_methods = map { "is_$_" } @logging_methods;
6411µs @detection_aliases = map { "is_$_" } @logging_aliases;
6516µs @logging_and_detection_methods = ( @logging_methods, @detection_methods );
661126µs113µs}
# spent 13µs making 1 call to Log::Any::Adapter::Util::BEGIN@52
67
68#pod =func logging_methods
69#pod
70#pod Returns a list of all logging method. E.g. "trace", "info", etc.
71#pod
72#pod =cut
73
7413µs
# spent 800ns within Log::Any::Adapter::Util::logging_methods which was called: # once (800ns+0s) by Log::Any::Adapter::Util::require_dynamic at line 53 of Log/Any/Proxy.pm
sub logging_methods { @logging_methods }
75
76#pod =func detection_methods
77#pod
78#pod Returns a list of detection methods. E.g. "is_trace", "is_info", etc.
79#pod
80#pod =cut
81
82sub detection_methods { @detection_methods }
83
84#pod =func logging_and_detection_methods
85#pod
86#pod Returns a list of logging and detection methods (but not aliases).
87#pod
88#pod =cut
89
9026µs
# spent 3µs within Log::Any::Adapter::Util::logging_and_detection_methods which was called 2 times, avg 1µs/call: # once (2µs+0s) by base::import at line 23 of Log/Any/Adapter/Base.pm # once (1µs+0s) by Log::Any::Manager::_require_dynamic at line 16 of Log/Any/Adapter/Null.pm
sub logging_and_detection_methods { @logging_and_detection_methods }
91
92#pod =func log_level_aliases
93#pod
94#pod Returns key/value pairs mapping aliases to "official" names. E.g. "err" maps
95#pod to "error".
96#pod
97#pod =cut
98
9914µs
# spent 2µs within Log::Any::Adapter::Util::log_level_aliases which was called: # once (2µs+0s) by Log::Any::Adapter::Util::require_dynamic at line 50 of Log/Any/Proxy.pm
sub log_level_aliases { %LOG_LEVEL_ALIASES }
100
101#pod =func logging_aliases
102#pod
103#pod Returns a list of logging alias names. These are the keys from
104#pod L</log_level_aliases>.
105#pod
106#pod =cut
107
108sub logging_aliases { @logging_aliases }
109
110#pod =func detection_aliases
111#pod
112#pod Returns a list of detection aliases. E.g. "is_err", "is_fatal", etc.
113#pod
114#pod =cut
115
116sub detection_aliases { @detection_aliases }
117
118#pod =func numeric_level
119#pod
120#pod Given a level name (or alias), returns the numeric value described above under
121#pod log level constants. E.g. "err" would return 3.
122#pod
123#pod =cut
124
125
# spent 14µs within Log::Any::Adapter::Util::numeric_level which was called 14 times, avg 1µs/call: # 14 times (14µs+0s) by Log::Any::Adapter::Util::require_dynamic at line 59 of Log/Any/Proxy.pm, avg 1µs/call
sub numeric_level {
126141µs my ($level) = @_;
127 my $canonical =
128142µs exists $LOG_LEVEL_ALIASES{$level} ? $LOG_LEVEL_ALIASES{$level} : $level;
1291415µs return $LOG_LEVELS{ uc($canonical) };
130}
131
132#pod =func dump_one_line
133#pod
134#pod Given a reference, returns a one-line L<Data::Dumper> dump with keys sorted.
135#pod
136#pod =cut
137
138sub dump_one_line {
139 my ($value) = @_;
140
141 return Data::Dumper->new( [$value] )->Indent(0)->Sortkeys(1)->Quotekeys(0)
142 ->Terse(1)->Dump();
143}
144
145#pod =func make_method
146#pod
147#pod Given a method name, a code reference and a package name, installs the code
148#pod reference as a method in the package.
149#pod
150#pod =cut
151
152sub make_method {
153 my ( $method, $code, $pkg ) = @_;
154
155 $pkg ||= caller();
1562126µs221µs
# spent 14µs (8+7) within Log::Any::Adapter::Util::BEGIN@156 which was called: # once (8µs+7µs) by Log::Any::BEGIN@11 at line 156
no strict 'refs';
# spent 14µs making 1 call to Log::Any::Adapter::Util::BEGIN@156 # spent 7µs making 1 call to strict::unimport
157 *{ $pkg . "::$method" } = $code;
158}
159
160#pod =func require_dynamic (DEPRECATED)
161#pod
162#pod Given a class name, attempts to load it via require unless the class
163#pod already has a constructor available. Throws an error on failure. Used
164#pod internally and may become private in the future.
165#pod
166#pod =cut
167
168
# spent 18.3ms (14.3+4.00) within Log::Any::Adapter::Util::require_dynamic which was called 2003 times, avg 9µs/call: # 2003 times (14.3ms+4.00ms) by Log::Any::get_logger at line 84 of Log/Any.pm, avg 9µs/call
sub require_dynamic {
1692003878µs my ($class) = @_;
170
171200318.5ms20033.94ms return 1 if $class->can('new'); # duck-type that class is loaded
# spent 3.94ms making 2003 calls to UNIVERSAL::can, avg 2µs/call
172
173116µs unless ( defined( eval "require $class; 1" ) )
# spent 39µs executing statements in string eval
174 { ## no critic (ProhibitStringyEval)
175 die $@;
176 }
177}
178
179#pod =func read_file (DEPRECATED)
180#pod
181#pod Slurp a file. Does *not* apply any layers. Used for testing and may
182#pod become private in the future.
183#pod
184#pod =cut
185
186sub read_file {
187 my ($file) = @_;
188
189 local $/ = undef;
190 open( my $fh, '<', $file )
191 or die "cannot open '$file': $!";
192 my $contents = <$fh>;
193 return $contents;
194}
195
196#pod =func cmp_deeply (DEPRECATED)
197#pod
198#pod Compares L<dump_one_line> results for two references. Also takes a test
199#pod label as a third argument. Used for testing and may become private in the
200#pod future.
201#pod
202#pod =cut
203
204sub cmp_deeply {
205 my ( $ref1, $ref2, $name ) = @_;
206
207 my $tb = Test::Builder->new();
208 $tb->is_eq( dump_one_line($ref1), dump_one_line($ref2), $name );
209}
210
211# 0.XX version loaded Log::Any and some adapters relied on this happening
212# behind the scenes. Since Log::Any now uses this module, we load Log::Any
213# via require after compilation to mitigate circularity.
2141300nsrequire Log::Any;
215
21614µs1;
217
218
219# vim: ts=4 sts=4 sw=4 et tw=75:
220
221__END__