tags:

views:

92

answers:

3

The code has been written and still so many developer are working. I need to increase the performance of the code. The code uses struts 1.2, Jdk 1.5.

I am reviewing code to increase the performance. What I need is steps to find bottlenecks in the code. How to avoid in future? How to refactor the code and tools for the same?

A: 

A very simple technique is to add trace statements in each layer, and method of interest with timeStamps.

After running a performance scenario, take a look at the trace log, to find out where the time is spent.

jeffo
This is not a good idea: 1) adding trace statements it labor intensive, 2) the added code tends to distort the execution time, and 3) analyzing the logs "by eye" is error prone.
Stephen C
@Stephen - Sometimes upping the logging level and checking through the logs can be useful. In a large complicated system there may be many layers and many applications. Spending time sifting through the logs can help you figure out *which* applications you need to profile.
Qwerky
+3  A: 

You can use Performance Monitoring Tool for J2EE Applications . Automating the process will help to understand the Performance problems. There are many Open Source Peformance Monitoring Tools Here are few .

Open Source Performance Monitoring Tools

InfraRED is a tool for monitoring performance of a J2EE application and diagnosing performance problems. It collects metrics about various aspects of an application's performance and makes it available for quantitative analysis of the application.

For Code Review you can use

PMD scans Java source code and looks for potential problems like:

Based on your requirement choose right tool .

Hope this helps

YetAnotherCoder
@JoseK I am not project manager.
Kamahire
I am reviewing code to increase the performance. What I need is steps for
Kamahire
so, @YetAnotherCoder has listed the apps which *YOU* can use to understand the problems in your code and then fix them. Also see FindBugs.
zengr
A: 

To find performance bottlenecks, you don't look at the source code and try to guess. You use a CPU profiler to see what part of the code are actually taking up the most time when it's running with your actual workload.

Since Java 1.6u7 (I think) the JDK comes with VisualVM, a simple but often sufficient profiling tool. Like all Java profilers, it can connect to a remote JVM via the network.

Michael Borgwardt
Could you provide me some good link how to use CPU profiler and VisualVM
Kamahire
@Kamahire: Here you go: http://blog.itplace.cz/visualvm/ or http://www.baptiste-wicht.com/2010/07/profile-applications-java-visualvm/
Michael Borgwardt