From: Kyle R. B. <mo...@vo...> - 2003-07-15 13:25:32
|
> > Looking a bit further, we noticed > > that the is_* methods (is_debug) were not implemented using that > > approach and that raised the question of wether or not they could be. > > Could those methods be created to just return undef or 1? > > Actually, please ignore my previous email, I looked at the code again > found an easy patch that'll do exactly what you suggested. I've run a > couple of benchmarks -- it improves performance of all is_xxx() methods > by a whopping 300%. Here's the fix -- Kevin and Erik, can you guys please > double-check if I've overlooked anything? That's great! Thanks for the quick response and action. To answer your earlier question, no we haven't yet run benchmarks, we were only considering the effect of having hundreds of if(is_debug) calls in our codebase. When we started worrying about the effect of log4perl integration, we wonderd about the implementation - and when we looked, we were glad to see that most of the expensive run-time operations were factored out to configuration and/or construction time. The is_* tests just seemed to not follow the design of the rest of the code. Any idea when a new release might happen? Thanks again, Kyle > Index: Logger.pm > =================================================================== > RCS file: /cvsroot/log4perl/Log-Log4perl/lib/Log/Log4perl/Logger.pm,v > retrieving revision 1.51 > diff -a -u -r1.51 Logger.pm > --- Logger.pm 6 Jul 2003 21:39:29 -0000 1.51 > +++ Logger.pm 15 Jul 2003 07:32:25 -0000 > @@ -157,10 +157,12 @@ > )) { > print " ($priority{$levelname} <= $level)\n" > if DEBUG; > - $self->{$levelname} = $coderef; > + $self->{$levelname} = $coderef; > + $self->{"is_$levelname"} = sub { 1 }; > }else{ > print " ($priority{$levelname} > $level)\n" if DEBUG; > - $self->{$levelname} = $noop; > + $self->{$levelname} = $noop; > + $self->{"is_$levelname"} = sub { 0 }; > } > > print(" Setting [$self] $self->{category}.$levelname to ", > @@ -574,10 +576,11 @@ > $_[0]->{$level}->(@_, $level); > }; > > - *{__PACKAGE__ . "::is_$lclevel"} = sub { > - return Log::Log4perl::Level::isGreaterOrEqual($_[0]->level(), > - $$level > - ); > + *{__PACKAGE__ . "::is_$lclevel"} = sub { > + $_[0]->{"is_" . $level}->(); > +# return Log::Log4perl::Level::isGreaterOrEqual($_[0]->level(), > +# $$level > +# ); > }; > > use strict qw(refs); > > > -- Mike > > Mike Schilli > log...@pe... > http://perlmeister.com > http://log4perl.sourceforge.net -- ------------------------------------------------------------------------------ Wisdom and Compassion are inseparable. -- Christmas Humphreys mo...@vo... http://www.voicenet.com/~mortis ------------------------------------------------------------------------------ |