Update filter method for adding isTraceEnabled condition to reduce calls to nanoTime method
Comment From: pivotal-cla
@Java4ye Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: mhalbritter
What's the problem with System.nanoTime?
Comment From: Java4ye
No,I mean the 'startTime' variable takes effect only when 'logger.isTraceEnabled()' , So I add this conditon to it
long startTime = 0;
if (logger.isTraceEnabled()) {
startTime = System.nanoTime();
}
And I marked the key points from the image below. @mhalbritter
Comment From: mhalbritter
I get that this variable is only used when logging on trace, but have you observed a performance problem with calling System.nanoTime()?
Comment From: Java4ye
@mhalbritter I didn't do that, but I found it in the for loop.
Comment From: wilkinsona
Until something shows up as a performance bottleneck, I think we should leaves things as they are. It may even be that the isTraceEnabled() check is slower than the call to System.nanoTime(). Thanks anyway for the proposal.