[slf4j-user] is*Enabled vs explicit method call performance measure
coldserenity
rmuntyan at softserveinc.com
Fri Aug 19 12:11:29 CEST 2011
Hi Chris,
I've reorganized the code a little bit. And now the results are closer to
1:1.
On 500M iterations with 5 attempts per each method I receive
Time to go with if statement: 478ms
Time to go with if statement: 477ms
Time to go with if statement: 475ms
Time to go with if statement: 467ms
Time to go with if statement: 471ms
Time to go with direct call: 317ms
Time to go with direct call: 313ms
Time to go with direct call: 309ms
Time to go with direct call: 309ms
Time to go with direct call: 310ms
Which seems more realistic. I've attached the
http://slf4j.42922.n3.nabble.com/file/n3267674/isDebugEnabledPerformanceTest-v2-src.zip
reworked code just in case.
Initial thought was to purely compare if it makes sense to wrap all of the
log.debug() statements with if (LOG.isDebugEnabled()){}. Well, I guess from
performance point of view it does not matter - because 150ms difference on
500M iterations is really not a difference.
However you brought up very good points on when the if
(LOG.isDebugEnabled()){} is really required. I think it's even worth adding
those to the FAQ http://www.slf4j.org/faq.html#logging_performance
Thanks for your time!
Regards,
Roman
--
View this message in context: http://slf4j.42922.n3.nabble.com/is-Enabled-vs-explicit-method-call-performance-measure-tp3267209p3267674.html
Sent from the slf4j - user mailing list archive at Nabble.com.
More information about the slf4j-user
mailing list