← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:39 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Log/Log4perl/Level.pm
StatementsExecuted 551 statements in 1.42ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
888378µs378µsLog::Log4perl::Level::::importLog::Log4perl::Level::import
88131µs31µsLog::Log4perl::Level::::add_priorityLog::Log4perl::Level::add_priority
11119µs19µsLog::Log4perl::Level::::BEGIN@5Log::Log4perl::Level::BEGIN@5
81114µs14µsLog::Log4perl::Level::::isGreaterOrEqualLog::Log4perl::Level::isGreaterOrEqual
11110µs12µsLog::Log4perl::Level::::BEGIN@6Log::Log4perl::Level::BEGIN@6
1119µs61µsLog::Log4perl::Level::::BEGIN@8Log::Log4perl::Level::BEGIN@8
1119µs60µsLog::Log4perl::Level::::BEGIN@13Log::Log4perl::Level::BEGIN@13
1117µs57µsLog::Log4perl::Level::::BEGIN@23Log::Log4perl::Level::BEGIN@23
1117µs14µsLog::Log4perl::Level::::BEGIN@7Log::Log4perl::Level::BEGIN@7
1116µs17µsLog::Log4perl::Level::::BEGIN@22Log::Log4perl::Level::BEGIN@22
1116µs33µsLog::Log4perl::Level::::BEGIN@16Log::Log4perl::Level::BEGIN@16
1116µs28µsLog::Log4perl::Level::::BEGIN@20Log::Log4perl::Level::BEGIN@20
1116µs29µsLog::Log4perl::Level::::BEGIN@14Log::Log4perl::Level::BEGIN@14
1116µs28µsLog::Log4perl::Level::::BEGIN@18Log::Log4perl::Level::BEGIN@18
1116µs28µsLog::Log4perl::Level::::BEGIN@17Log::Log4perl::Level::BEGIN@17
1116µs28µsLog::Log4perl::Level::::BEGIN@15Log::Log4perl::Level::BEGIN@15
1115µs28µsLog::Log4perl::Level::::BEGIN@19Log::Log4perl::Level::BEGIN@19
0000s0sLog::Log4perl::Level::::get_higher_levelLog::Log4perl::Level::get_higher_level
0000s0sLog::Log4perl::Level::::get_lower_levelLog::Log4perl::Level::get_lower_level
0000s0sLog::Log4perl::Level::::is_validLog::Log4perl::Level::is_valid
0000s0sLog::Log4perl::Level::::newLog::Log4perl::Level::new
0000s0sLog::Log4perl::Level::::numericallyLog::Log4perl::Level::numerically
0000s0sLog::Log4perl::Level::::to_LogDispatch_stringLog::Log4perl::Level::to_LogDispatch_string
0000s0sLog::Log4perl::Level::::to_levelLog::Log4perl::Level::to_level
0000s0sLog::Log4perl::Level::::to_priorityLog::Log4perl::Level::to_priority
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1###############r###################################
2package Log::Log4perl::Level;
3##################################################
4
5328µs119µs
# spent 19µs within Log::Log4perl::Level::BEGIN@5 which was called: # once (19µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 5
use 5.006;
# spent 19µs making 1 call to Log::Log4perl::Level::BEGIN@5
6317µs214µs
# spent 12µs (10+2) within Log::Log4perl::Level::BEGIN@6 which was called: # once (10µs+2µs) by Log::Log4perl::Logger::BEGIN@10 at line 6
use strict;
# spent 12µs making 1 call to Log::Log4perl::Level::BEGIN@6 # spent 2µs making 1 call to strict::import
7316µs222µs
# spent 14µs (7+7) within Log::Log4perl::Level::BEGIN@7 which was called: # once (7µs+7µs) by Log::Log4perl::Logger::BEGIN@10 at line 7
use warnings;
# spent 14µs making 1 call to Log::Log4perl::Level::BEGIN@7 # spent 8µs making 1 call to warnings::import
8323µs2112µs
# spent 61µs (9+51) within Log::Log4perl::Level::BEGIN@8 which was called: # once (9µs+51µs) by Log::Log4perl::Logger::BEGIN@10 at line 8
use Carp;
# spent 61µs making 1 call to Log::Log4perl::Level::BEGIN@8 # spent 52µs making 1 call to Exporter::import
9
10# log4j, for whatever reason, puts 0 as all and MAXINT as OFF.
11# this seems less optimal, as more logging would imply a higher
12# level. But oh well. Probably some brokenness that has persisted. :)
13322µs2112µs
# spent 60µs (9+51) within Log::Log4perl::Level::BEGIN@13 which was called: # once (9µs+51µs) by Log::Log4perl::Logger::BEGIN@10 at line 13
use constant ALL_INT => 0;
# spent 60µs making 1 call to Log::Log4perl::Level::BEGIN@13 # spent 52µs making 1 call to constant::import
14321µs253µs
# spent 29µs (6+24) within Log::Log4perl::Level::BEGIN@14 which was called: # once (6µs+24µs) by Log::Log4perl::Logger::BEGIN@10 at line 14
use constant TRACE_INT => 5000;
# spent 29µs making 1 call to Log::Log4perl::Level::BEGIN@14 # spent 24µs making 1 call to constant::import
15326µs252µs
# spent 28µs (6+23) within Log::Log4perl::Level::BEGIN@15 which was called: # once (6µs+23µs) by Log::Log4perl::Logger::BEGIN@10 at line 15
use constant DEBUG_INT => 10000;
# spent 28µs making 1 call to Log::Log4perl::Level::BEGIN@15 # spent 23µs making 1 call to constant::import
16317µs261µs
# spent 33µs (6+28) within Log::Log4perl::Level::BEGIN@16 which was called: # once (6µs+28µs) by Log::Log4perl::Logger::BEGIN@10 at line 16
use constant INFO_INT => 20000;
# spent 33µs making 1 call to Log::Log4perl::Level::BEGIN@16 # spent 28µs making 1 call to constant::import
17317µs251µs
# spent 28µs (6+23) within Log::Log4perl::Level::BEGIN@17 which was called: # once (6µs+23µs) by Log::Log4perl::Logger::BEGIN@10 at line 17
use constant WARN_INT => 30000;
# spent 28µs making 1 call to Log::Log4perl::Level::BEGIN@17 # spent 23µs making 1 call to constant::import
18317µs250µs
# spent 28µs (6+22) within Log::Log4perl::Level::BEGIN@18 which was called: # once (6µs+22µs) by Log::Log4perl::Logger::BEGIN@10 at line 18
use constant ERROR_INT => 40000;
# spent 28µs making 1 call to Log::Log4perl::Level::BEGIN@18 # spent 22µs making 1 call to constant::import
19325µs250µs
# spent 28µs (5+22) within Log::Log4perl::Level::BEGIN@19 which was called: # once (5µs+22µs) by Log::Log4perl::Logger::BEGIN@10 at line 19
use constant FATAL_INT => 50000;
# spent 28µs making 1 call to Log::Log4perl::Level::BEGIN@19 # spent 22µs making 1 call to constant::import
20321µs251µs
# spent 28µs (6+22) within Log::Log4perl::Level::BEGIN@20 which was called: # once (6µs+22µs) by Log::Log4perl::Logger::BEGIN@10 at line 20
use constant OFF_INT => (2 ** 31) - 1;
# spent 28µs making 1 call to Log::Log4perl::Level::BEGIN@20 # spent 22µs making 1 call to constant::import
21
22319µs227µs
# spent 17µs (6+10) within Log::Log4perl::Level::BEGIN@22 which was called: # once (6µs+10µs) by Log::Log4perl::Logger::BEGIN@10 at line 22
no strict qw(refs);
# spent 17µs making 1 call to Log::Log4perl::Level::BEGIN@22 # spent 10µs making 1 call to strict::unimport
233668µs2107µs
# spent 57µs (7+50) within Log::Log4perl::Level::BEGIN@23 which was called: # once (7µs+50µs) by Log::Log4perl::Logger::BEGIN@10 at line 23
use vars qw(%PRIORITY %LEVELS %SYSLOG %L4P_TO_LD);
# spent 57µs making 1 call to Log::Log4perl::Level::BEGIN@23 # spent 50µs making 1 call to vars::import
24
251700ns%PRIORITY = (); # unless (%PRIORITY);
261500ns%LEVELS = () unless (%LEVELS);
271200ns%SYSLOG = () unless (%SYSLOG);
281500ns%L4P_TO_LD = () unless (%L4P_TO_LD);
29
30
# spent 31µs within Log::Log4perl::Level::add_priority which was called 8 times, avg 4µs/call: # once (7µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 59 # once (4µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 66 # once (4µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 60 # once (4µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 64 # once (4µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 61 # once (3µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 62 # once (3µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 63 # once (3µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 65
sub add_priority {
3184µs my ($prio, $intval, $syslog, $log_dispatch_level) = @_;
3283µs $prio = uc($prio); # just in case;
33
3485µs $PRIORITY{$prio} = $intval;
3587µs $LEVELS{$intval} = $prio;
36
37 # Set up the mapping between Log4perl integer levels and
38 # Log::Dispatch levels
39 # Note: Log::Dispatch uses the following levels:
40 # 0 debug
41 # 1 info
42 # 2 notice
43 # 3 warning
44 # 4 error
45 # 5 critical
46 # 6 alert
47 # 7 emergency
48
49 # The equivalent Log::Dispatch level is optional, set it to
50 # the highest value (7=emerg) if it's not provided.
5181µs $log_dispatch_level = 7 unless defined $log_dispatch_level;
52
5383µs $L4P_TO_LD{$prio} = $log_dispatch_level;
54
55823µs $SYSLOG{$prio} = $syslog if defined($syslog);
56}
57
58# create the basic priorities
5912µs17µsadd_priority("OFF", OFF_INT, -1, 7);
# spent 7µs making 1 call to Log::Log4perl::Level::add_priority
6011µs14µsadd_priority("FATAL", FATAL_INT, 0, 7);
# spent 4µs making 1 call to Log::Log4perl::Level::add_priority
611900ns14µsadd_priority("ERROR", ERROR_INT, 3, 4);
# spent 4µs making 1 call to Log::Log4perl::Level::add_priority
621800ns13µsadd_priority("WARN", WARN_INT, 4, 3);
# spent 3µs making 1 call to Log::Log4perl::Level::add_priority
631900ns13µsadd_priority("INFO", INFO_INT, 6, 1);
# spent 3µs making 1 call to Log::Log4perl::Level::add_priority
641800ns14µsadd_priority("DEBUG", DEBUG_INT, 7, 0);
# spent 4µs making 1 call to Log::Log4perl::Level::add_priority
651800ns13µsadd_priority("TRACE", TRACE_INT, 8, 0);
# spent 3µs making 1 call to Log::Log4perl::Level::add_priority
661700ns14µsadd_priority("ALL", ALL_INT, 8, 0);
# spent 4µs making 1 call to Log::Log4perl::Level::add_priority
67
68# we often sort numerically, so a helper func for readability
69sub numerically {$a <=> $b}
70
71###########################################
72
# spent 378µs within Log::Log4perl::Level::import which was called 8 times, avg 47µs/call: # once (60µs+0s) by Log::Log4perl::BEGIN@13 at line 13 of Log/Log4perl.pm # once (57µs+0s) by Log::Log4perl::Appender::BEGIN@9 at line 9 of Log/Log4perl/Appender.pm # once (55µs+0s) by Log::Log4perl::Filter::BEGIN@9 at line 9 of Log/Log4perl/Filter.pm # once (43µs+0s) by Log::Log4perl::Filter::Boolean::BEGIN@10 at line 10 of Log/Log4perl/Filter/Boolean.pm # once (42µs+0s) by Log::Log4perl::Layout::SimpleLayout::BEGIN@11 at line 11 of Log/Log4perl/Layout/SimpleLayout.pm # once (42µs+0s) by Log::Log4perl::Layout::PatternLayout::BEGIN@14 at line 14 of Log/Log4perl/Layout/PatternLayout.pm # once (41µs+0s) by Log::Log4perl::Logger::BEGIN@10 at line 10 of Log/Log4perl/Logger.pm # once (39µs+0s) by Log::Log4perl::Config::BEGIN@9 at line 9 of Log/Log4perl/Config.pm
sub import {
73###########################################
7487µs my($class, $namespace) = @_;
75
7685µs if(defined $namespace) {
77 # Export $OFF, $FATAL, $ERROR etc. to
78 # the given namespace
79 $namespace .= "::" unless $namespace =~ /::$/;
80 } else {
81 # Export $OFF, $FATAL, $ERROR etc. to
82 # the caller's namespace
8387µs $namespace = caller(0) . "::";
84 }
85
86847µs for my $key (keys %PRIORITY) {
876422µs my $name = "$namespace$key";
886426µs my $value = $PRIORITY{$key};
8964129µs *{"$name"} = \$value;
906425µs my $nameint = "$namespace${key}_INT";
916421µs my $func = uc($key) . "_INT";
9264111µs *{"$nameint"} = \&$func;
93 }
94}
95
96##################################################
97sub new {
98##################################################
99 # We don't need any of this class nonsense
100 # in Perl, because we won't allow subclassing
101 # from this. We're optimizing for raw speed.
102}
103
104##################################################
105sub to_priority {
106# changes a level name string to a priority numeric
107##################################################
108 my($string) = @_;
109
110 if(exists $PRIORITY{$string}) {
111 return $PRIORITY{$string};
112 }else{
113 croak "level '$string' is not a valid error level (".join ('|', keys %PRIORITY),')';
114 }
115}
116
117##################################################
118sub to_level {
119# changes a priority numeric constant to a level name string
120##################################################
121 my ($priority) = @_;
122 if (exists $LEVELS{$priority}) {
123 return $LEVELS{$priority}
124 }else {
125 croak("priority '$priority' is not a valid error level number (",
126 join("|", sort numerically keys %LEVELS), "
127 )");
128 }
129
130}
131
132##################################################
133sub to_LogDispatch_string {
134# translates into strings that Log::Dispatch recognizes
135##################################################
136 my($priority) = @_;
137
138 confess "do what? no priority?" unless defined $priority;
139
140 my $string;
141
142 if(exists $LEVELS{$priority}) {
143 $string = $LEVELS{$priority};
144 }
145
146 # Log::Dispatch idiosyncrasies
147 if($priority == $PRIORITY{WARN}) {
148 $string = "WARNING";
149 }
150
151 if($priority == $PRIORITY{FATAL}) {
152 $string = "EMERGENCY";
153 }
154
155 return $string;
156}
157
158###################################################
159sub is_valid {
160###################################################
161 my $q = shift;
162
163 if ($q =~ /[A-Z]/) {
164 return exists $PRIORITY{$q};
165 }else{
166 return $LEVELS{$q};
167 }
168
169}
170
171sub get_higher_level {
172 my ($old_priority, $delta) = @_;
173
174 $delta ||= 1;
175
176 my $new_priority = 0;
177
178 foreach (1..$delta){
179 #so the list is TRACE, DEBUG, INFO, WARN, ERROR, FATAL
180 # but remember, the numbers go in reverse order!
181 foreach my $p (sort numerically keys %LEVELS){
182 if ($p > $old_priority) {
183 $new_priority = $p;
184 last;
185 }
186 }
187 $old_priority = $new_priority;
188 }
189 return $new_priority;
190}
191
192sub get_lower_level {
193 my ($old_priority, $delta) = @_;
194
195 $delta ||= 1;
196
197 my $new_priority = 0;
198
199 foreach (1..$delta){
200 #so the list is FATAL, ERROR, WARN, INFO, DEBUG, TRACE
201 # but remember, the numbers go in reverse order!
202 foreach my $p (reverse sort numerically keys %LEVELS){
203 if ($p < $old_priority) {
204 $new_priority = $p;
205 last;
206 }
207 }
208 $old_priority = $new_priority;
209 }
210 return $new_priority;
211}
212
213
# spent 14µs within Log::Log4perl::Level::isGreaterOrEqual which was called 8 times, avg 2µs/call: # 8 times (14µs+0s) by Log::Log4perl::Logger::set_output_methods at line 213 of Log/Log4perl/Logger.pm, avg 2µs/call
sub isGreaterOrEqual {
21482µs my $lval = shift;
21582µs my $rval = shift;
216
217 # in theory, we should check if the above really ARE valid levels.
218 # but we just use numeric comparison, since they aren't really classes.
219
220 # oh, yeah, and 'cuz level ints go from 0 .. N with 0 being highest,
221 # these are reversed.
222816µs return $lval <= $rval;
223}
224
225######################################################################
226#
227# since the integer representation of levels is reversed from what
228# we normally want, we don't want to use < and >... instead, we
229# want to use this comparison function
230
231
23219µs1;
233
234__END__