From: Erik W. S. <er...@se...> - 2003-07-18 04:12:18
|
Sweet... nice bit o' work there. And yeah, much speedier. :) Truth be told, never worried much about performance for most things Perl, as the interpreter and RE isn't the speediest thing in the planet. -e Mike Schilli wrote: >On Mon, 14 Jul 2003, Kyle R. Burton wrote: > > > >>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? > >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 > > >------------------------------------------------------- >This SF.Net email sponsored by: Parasoft >Error proof Web apps, automate testing & more. >Download & eval WebKing and get a free book. >www.parasoft.com/bulletproofapps1 >_______________________________________________ >log4perl-devel mailing list >log...@li... >https://lists.sourceforge.net/lists/listinfo/log4perl-devel > > > |