views:

503

answers:

4

I know this has been asked before, but I have not found anything recent that really gives a good answer. I'm trying to find a free profiler for eclipse that works well. I would like a graphical breakdown of execution time in particular. I've tried TPTP but have had no luck at all with GUI apps (it took almost a minute for a GUI app to start and was virtually unusable on screen - it uses a lot of Java OpenGL, so I'm not sure if it has to do with that). I liked YourKit, but unfortunately it's not free. I even tried switching to NetBeans since they have a built in profiler.

If anyone has had success with particular profilers (even if it was TPTP), I'd like to hear about it. Any recommendations would be greatly appreciated.

thanks, Jeff

+4  A: 

VisualVM works great and is included in recent JDK releases. It's not an eclipse plugin, but does that really matter?

And BTW: TPTP is an unholy abomination of overengineered crap. Getting it to work involves sacrificing at least one black goat, and getting any results takes forever.

Michael Borgwardt
Ah ... a *black* one! Thanks for the hint.
Stephen C
I like VisualVM, but can I get an execution time graph from there?
Jeff Storey
@Jeff: not sure what an execution time graph is. VisualVM mainly offers a list of hotspots and can show a call tree ordered by time share for each of them. That's been enough for me.
Michael Borgwardt
Ah, yes it was the CPU hot spots I was looking for. I forgot that was in there. Thanks!
Jeff Storey
VisualVM would work if Jeff is using Java 6, right? If I remember correctly, in a project we could not use Visual VM because we had to use 1.5 . I could be remembering it wrong though.
CoolBeans
I am using Java 6, so no problem here.
Jeff Storey
visualvm has an eclipse launcher - https://visualvm.dev.java.net/eclipse-launcher.html
Thorbjørn Ravn Andersen
Fantastic. I didn't know about that. I'll try it out and let you know how it goes. Thanks!
Jeff Storey
Hmm..VisualVM seems to suffer from some of the same problems TPTP. The GUI becomes virtually unusable with the OpenGL code. Guess I'll have to stick to a pay profiler...
Jeff Storey
Note to my previous comment. It only has problems when CPU execution time profiling is on. Probably because of Java OpenGL's constant calls to rerender the scene.
Jeff Storey
+1  A: 

The reason you failed to find any good free Java profilers with Eclipse integration is simple - there aren't any. To be fair I think that the only good free Java profiler is the one bundled with NetBeans and it's far from what JProfiler and YourKit bring to the table.

I was spent a considerable amount of time trying to find a nice free Java profiler, spent some time trying to use TPTP(which was a nightmare) and in the end I bought a YourKit licence :-) I hope the situation will some day improve, but this seems unlikely...

Bozhidar Batsov
Thanks. Can you elaborate on what JProfiler and YourKit provide in their profiler that NetBeans doesn't? The only one I've used is YourKit and I was trying to switch to netbeans, but I've had some groovy integration problems. But if the netbeans one isn't worth it, then I might abandon that effort. Thanks.
Jeff Storey
@Jeff: AFAIK VisualVM is actually based on the Netbeans profiler. And yeah, I've found it often fail to do CPU profiling for Groovy apps as well.
Michael Borgwardt
That's interesting. I didn't realize it was based on Netbeans. The issue I had with groovy though wasn't with profiling (didn't even make it that far). It was when I tried to put groovy files in src/main/java (maven project) rather than src/main/groovy. http://stackoverflow.com/questions/2696121/netbeans-6-8-groovy-files-in-src-main-java
Jeff Storey
@Jeff, the NetBeans profiler instruments the profiled code which adds some overhead which sometimes might be undesirable. It also tends to freeze from time to time when profiling highly sophisticated scenarios. YourKit and JProfiler excel at non-intrusive profiling, they feature some nice JEE extensions and have much more advanced memory profiling capabilities(and I often have to track allocations, memory leaks, etc). NetBeans's profiler and VJMV by association will probably suit most people, but when you're in big trouble they might not be what you need...
Bozhidar Batsov
Appreciate the explanation, thanks.
Jeff Storey
A: 

If you can afford it, I would recommend using Dynatrace Client and Dynatrace Ajax Client. The Dynatrace Ajax client is free but the server side profiler you will have to pay for. After using many profilers, I found them to be the best and the easiest to work with.

CoolBeans
+1  A: 

You say it takes a minute? I assume it should take maybe 5 seconds max. If so, that means 55 out of those 60 seconds are being spent doing something that doesn't need to be done.

If you just pause Eclipse during that minute, and look at the stack (called taking a stackshot), chances are 55/60 that you will see exactly what it is. If you pause it several times, it will show you that every time you pause it, or nearly every time, since you are unlikely to catch it during the 1/12th of the time that it is actually doing useful work.

I know this doesn't give you the fancy graphics you asked for.
But it will find the problem in about a minute.

Mike Dunlavey
Thanks for the suggestion. My app only normally takes a few seconds to start. When I ran it with TPTP it took 60 seconds, so I naturally assume it's an issue with the instrumentation of the code. That was my last attempt at TPTP.
Jeff Storey
@Jeff Storey: What I do if it only takes a few seconds to run is a) wrap a loop around the processing code, b) run it with a data-watch to slow it down, or 3) just try to be quick about stabbing it in those few seconds. Anyway, so maybe 11/12 isn't the bad-fraction. Regardless, if there is a significant fraction of time to be saved, crude sampling will find it. Maybe you don't actually have enough of a problem to worry about, but (forgive me) I'm a stuck record on SO patiently explaining why that method works.
Mike Dunlavey
@Mike. One of my real issues is there is some 3rd party GUI code that was taking a while to run. So it's difficult to really track down with this method since I need to be doing certain behavior on the GUI, which is really why I needed a profiler to work for me. It looks like YourKit does the trick pretty well though.
Jeff Storey
@Jeff Storey: Well I'm glad you found something that works for you.
Mike Dunlavey