Profile of Log/Any/IfLOG.pm

← Index
NYTProf Performance Profile «line view»
For -e
Run on Thu Jun 30 16:16:00 2016
Reported on Thu Jun 30 16:16:08 2016

Filename | /home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/Log/Any/IfLOG.pm
Statements | Executed 17 statements in 54µs

Subroutines
Calls | P | F | Exclusive Time | Inclusive Time | Subroutine
--- | --- | --- | --- | --- | ---
1 | 1 | 1 | 26µs | 44µs | Log::Any::IfLOG::::import Log::Any::IfLOG::import
1 | 1 | 1 | 8µs | 12µs | Log::Any::IfLOG::::__log_singleton Log::Any::IfLOG::__log_singleton
1 | 1 | 1 | 5µs | 5µs | Log::Any::IfLOG::::__log_enabled Log::Any::IfLOG::__log_enabled
1 | 1 | 1 | 5µs | 5µs | Log::Any::IfLOG::DumbObj::::newLog::Any::IfLOG::DumbObj::new
0 | 0 | 0 | 0s | 0s | Log::Any::IfLOG::DumbObj::::AUTOLOADLog::Any::IfLOG::DumbObj::AUTOLOAD
0 | 0 | 0 | 0s | 0s | Log::Any::IfLOG::::get_logger Log::Any::IfLOG::get_logger

Call graph for these subroutines as a Graphviz dot language file.

Line | State ments | Time on line | Calls | Time in subs | Code
--- | --- | --- | --- | --- | ---
1 |  |  |  |  | package Log::Any::IfLOG;
2 |  |  |  |  |
3 | 1 | 700ns |  |  | our $DATE = '2016-06-16'; # DATE
4 | 1 | 200ns |  |  | our $VERSION = '0.08'; # VERSION
5 |  |  |  |  |
6 |  |  |  |  | our $DEBUG;
7 |  |  |  |  | our $ENABLE_LOG;
8 |  |  |  |  |
9 | 1 | 300ns |  |  | my $log_singleton;
10 |  |  |  |  | # spent 12µs (8+5) within Log::Any::IfLOG::__log_singleton which was called: # once (8µs+5µs) by Log::Any::IfLOG::import at line 38 sub __log_singleton {
11 | 1 | 2µs | 1 | 5µs | if (!$log_singleton) { $log_singleton = Log::Any::IfLOG::DumbObj->new } # spent 5µs making 1 call to Log::Any::IfLOG::DumbObj::new
12 | 1 | 4µs |  |  | $log_singleton;
13 |  |  |  |  | }
14 |  |  |  |  |
15 |  |  |  |  | # spent 5µs within Log::Any::IfLOG::__log_enabled which was called: # once (5µs+0s) by Log::Any::IfLOG::import at line 32 sub __log_enabled {
16 | 1 | 1µs |  |  | if (defined $ENABLE_LOG) {
17 |  |  |  |  | return $ENABLE_LOG;
18 |  |  |  |  | } elsif ($INC{'Log/Any.pm'}) {
19 |  |  |  |  | # Log::Any has been loaded, so we have absorbed the cost anyway
20 |  |  |  |  | return 1;
21 |  |  |  |  | } else {
22 |  |  |  |  | return
23 |  |  |  |  | $ENV{LOG} || $ENV{TRACE} || $ENV{DEBUG} ||
24 | 1 | 11µs |  |  | $ENV{VERBOSE} || $ENV{QUIET} || $ENV{LOG_LEVEL};
25 |  |  |  |  | }
26 |  |  |  |  | }
27 |  |  |  |  |
28 |  |  |  |  | # spent 44µs (26+18) within Log::Any::IfLOG::import which was called: # once (26µs+18µs) by DateTime::Format::Alami::BEGIN@9 at line 9 of DateTime/Format/Alami.pm sub import {
29 | 1 | 800ns |  |  | my $self = shift;
30 |  |  |  |  |
31 | 1 | 900ns |  |  | my $caller = caller();
32 | 1 | 8µs | 1 | 5µs | if (__log_enabled()) { # spent 5µs making 1 call to Log::Any::IfLOG::__log_enabled
33 |  |  |  |  | require Log::Any;
34 |  |  |  |  | Log::Any->_export_to_caller($caller, @_);
35 |  |  |  |  | } else {
36 | 1 | 2µs |  |  | my $saw_log_param = grep { $_ eq '$log' } @_;
37 | 1 | 600ns |  |  | if ($saw_log_param) {
38 | 1 | 1µs | 1 | 12µs | __log_singleton(); # to init $log_singleton # spent 12µs making 1 call to Log::Any::IfLOG::__log_singleton
39 | 1 | 5µs |  |  | *{"$caller\::log"} = \$log_singleton;
40 |  |  |  |  | }
41 |  |  |  |  | }
42 |  |  |  |  | }
43 |  |  |  |  |
44 |  |  |  |  | sub get_logger {
45 |  |  |  |  | if (__log_enabled()) {
46 |  |  |  |  | require Log::Any;
47 |  |  |  |  | my $class = shift;
48 |  |  |  |  | if ($class eq 'Log::Any::IfLOG') {
49 |  |  |  |  | Log::Any->get_logger(@_);
50 |  |  |  |  | } else {
51 |  |  |  |  | Log::Any::get_logger($class, @_);
52 |  |  |  |  | }
53 |  |  |  |  | } else {
54 |  |  |  |  | return __log_singleton();
55 |  |  |  |  | }
56 |  |  |  |  | }
57 |  |  |  |  |
58 |  |  |  |  | package
59 |  |  |  |  | Log::Any::IfLOG::DumbObj;
60 | 2 | 9µs |  |  | # spent 5µs within Log::Any::IfLOG::DumbObj::new which was called: # once (5µs+0s) by Log::Any::IfLOG::__log_singleton at line 11 sub new { my $o = ""; bless \$o, shift }
61 |  |  |  |  | sub AUTOLOAD { 0 }
62 |  |  |  |  |
63 | 1 | 6µs |  |  | 1;
64 |  |  |  |  | # ABSTRACT: Load Log::Any only if "logging is enabled"
65 |  |  |  |  |
66 |  |  |  |  | __END__