views:

3657

answers:

12

I am looking for the Java equivalent of gprof. I did a little Java profiling using System.getCurrentMillis(), and saw several GUI tools which seem too much. A good compromise could be a text-based Java profiler, preferably free or low-cost, which works in either Windows XP or Linux.

+1  A: 

JProbe from Quest Software will rock your world ;)

But it has a price... You can use the trial for 10 days though ;)

edit: I see that they also have a freeware version with only the Memory Heap Dump Analysis... Quite nice!

Arcturus
+13  A: 

A list of Open source JAVA profilers that you may find useful.

Pascal
+10  A: 

You may want to check out the following:

David Schlosnagle
One correction--visual VM is a stand alone tool that is built on the Netbeans platform.The Netbeans Profiler is a profiling tool integrated into the Netbeans IDE that's intended for use as part of your day-to-day development activities.Same functionality, different UI experience.
James Schek
+2  A: 

We've been using JProfiler where I work and are very pleased.

Joseph Gordon
+2  A: 

Absolutely no need to go non-free, also the text based profiling tools that exist are nowhere near as easy to use as the GUI ones. Specifically for profiling having flexible views that you can easily resort, filter, slice and dice is a huge plus.

My recommendation: go with Netbeans and its included profiler or the above mentioned VisualVM if you have access to JDK 1.6 update 7 or higher (they are basically the same product).

Boris Terzic
+5  A: 

You may checkout JAmon http://jamonapi.sourceforge.net/). It's quite easy and gives very good facility to monitor a part of code or entire function flow.

It uses Proxy mechanism and at any point of time you can generate the report of performance by calling just one method.

It does not have any fancy GUI but if you are developer and you want to develop your own custom solution to monitor the things, I guess this one would do the job.

jatanp
+3  A: 

YourKit does a GREAT job at profiling Java applications. It is a commercial project, but it does have demo licenses available (30 days if I remember correctly).

John Meagher
+1  A: 

JProfiler works well - easy to setup in eclipse, and pretty much no configuration. Just pretty the button to launch it in the profiler instead of the normal test/run config.

Michael Neale
A: 

JXInsight has been labeled the "gold standard" in Java application performance management. It can be used in development, test and production which cannot be said for other tools. Its Probes technology out performs all other profilers by 20x-100x in SPECjvm2008 benchmarks. It has more than 4000+ system properties to tweak the runtime overhead and data collection and ships with 600+ technology specific extensions.

http://www.jinspired.com/products/jxinsight/

A: 

I know Netbean is a GUI tool, but it has a great profiler, easy to use, I use it daily.

Dan
+1  A: 

I searched for this myself, and found that the free VisualVM is very good. Be sure to download the most recent version. (An older version also comes with the Java JDK).

There is a Eclipse plugin available, but it doesn't offer much. The profiler doesn't wait with starting your program until it's ready to profile, so you have to manually set some sleep timer or so.

Peterdk
Yes, I also tried VisualVM 1.2. It was very useful.
Yuval F
+1  A: 

Java equivalent of gprof?

You can do better than that.

Mike Dunlavey
Thanks Mike. As you said, "Programmers tend to be skeptical of this technique unless they've used it themselves." This looks interesting, to say the least, so I promise to give it a shot. Nevertheless, I have used gprof successfully in the past, so I view it as an imperfect but useful tool.
Yuval F
@Yuval: Right. There are some problems that gprof can find. Just today I was sampling an app, and about 20% of its time was spent in stuff that gprof could have found. A lot was not, like I/O and extra calls to math library routines.
Mike Dunlavey
@Yuval: Bear with me. If gprof finds something costing 20% (out of 10 seconds) and that something can be optimized to around zero, now the program takes 8 seconds, and gprof has played all its cards. Chances are there are other ways to pick up substantial percentages, but if you can't find them, you're stuck with your 8 seconds.
Mike Dunlavey