I need to optimize a java application. It makes some 3rd party calls. I need some good tool to accurately measure the time taken by individual api calls. To give an idea of complexity- the application takes a data source file containing 10 lakh rows, and it takes around one hour to complete the processing. As a part of processing , it makes some 3rd party calls (including some network calls). I need to identify which calls are taking more time then others, and based on that, find out a way to optimize the application. Any suggestions would be appreciated.

+1  A: 

I've been using YourKit a few times and what quite happy with it. I've however never profiled a long-running operation.

Is the processing the same for each row? In which case the size of the input file doesn't really matter. You could profile a subset to figure out which calls are expensive.

yep.. i can cut the input size!! thanx
Nitin Garg

visualvm (part of the SDK) and Java 7 can produce detailed profiling.

+4  A: 
+1  A: 

It sounds like a normal profiler might not be the right tool in this case, since they're geared towards measuring the CPU time taken by the program being profiled rather than external APIs that it calls, and they tend to incur a high overhead of their own and collect a large amount of data that would probably overwhelm your system if left running for a long time.

If you really need to collect performance data over such a long time, and mainly for external calls, then Perf4J is probably a better tool.

Michael Borgwardt
are you sure perf4j would work??I tried using System.currentTimeMillis(). It doest seem to give good enough accuracy.
Nitin Garg
@Nitin: presumably it uses System.nanoTime(), which has much better accuracy. But from your description I got the impression that even millisecond granularity would be sufficient for the things taking the most time in your case (like third-party components called via network)´.
Michael Borgwardt
+1  A: 

In our office we use YourKit profiler on a day to day basis. It's really light weight and serves most of the performance related use cases we have had.

But I have also used Visual VM. It's free and fast. You may first want to give Visual VM a try before going towards YourKit (YourKit is not freeware).


I use profiler in NetBeans (it is really brilliant and already built in, no need to install plugin) or JVisualVM when not using NetBeans.

+1  A: 

Try OPNET's Panorama software product

Andy Fields