Subscribe to jobiz's Blog        RSS Feed
-----

Java Performance

Icon Leave Comment
I work on Large projects for multinational companies as a technical Lead. My company developes and delivered strategig software solutions to these companies. One of the issues that ALWAYS comes up is performace.Yes there are books on how to make JAVA more efficient, but one of the most common causes of bad performance has nothing to do with the application code whatsoever. LOGGING is one of the major causes of performance degradation in large applications.

 logger.debug("I am here with " + someVariable + someValue)


the above concactenates a string which is an expansive JAVA operation.
Doing it like this helps if using LOG4J

if (logger.isDebugEnabled()
logger.debug("I am here with " + someVariable + someValue)



The conditional check saves the trouble of running the logger at all depending on its settings.
Note that even when set to just log ERRORs, the actual work of concactenation still gets performed.

An Even better way to do this is to use a String Buffer to append the values you want to log...Like

If(logger.isDebugEnabled ())

			logger.debug(new StringBuffer(200).append(" I am here with   ").append

					(someVariable).append(SomeValue).append

					(someVariable).toString());

0 Comments On This Entry

 

February 2022

S M T W T F S
  12345
6 7 89101112
13141516171819
20212223242526
2728     

Tags

    Recent Entries

    Search My Blog

    2 user(s) viewing

    2 Guests
    0 member(s)
    0 anonymous member(s)