View RSS Feed

Advanced Java

Performance improvement of a Java application

Rate this Entry
by , 01-08-2012 at 12:45 PM (3812 Views)
Follow these steps to improve performance of your Java application.

Always Pool valuable system resources like threads, database connections, socket connections.
Optimize your I/O operations by using buffering when writing to and reading from files and/or streams.
Minimize network overheads by retrieving several related items simultaneously in one remote invocation if possible.
Apply the following performance tips in your code

Use ArrayLists, HashMap as opposed to Vector, Hashtable
Set the initial capacity of a collection.
Minimize the use of casting or runtime type checking like instanceof in your code.
Do not compute constants inside a large loop.
Avoid using System.out.println.
Minimize calls to Date, Calendar, etc related classes.
Minimize JNI calls in your code.

Submit "Performance improvement of a Java application" to Facebook Submit "Performance improvement of a Java application" to Digg Submit "Performance improvement of a Java application" to del.icio.us Submit "Performance improvement of a Java application" to StumbleUpon Submit "Performance improvement of a Java application" to Google

Comments

  1. doWhile's Avatar
    • |
    • permalink
    One important point not in your post - profile your code. Print out time in milliseconds If you are having performance issues, know where the issue lies rather than guessing and optimizing something that may not even have an notable impact on performance. Tools like JConsole are in the JDK for a reason, and even something as simple as printing out the time it takes to complete a process are invaluable to pinpointing performance issues.