views:

270

answers:

4

I've heard a lot about profiling. What is this all about? As far as I understand this is some kind of performance measurement but can someone elaborate this on more clearly so that a newbie can grasp the idea. Also, I use Eclipse IDE for my Java program. Can I profile my program using Eclipse IDE? What are the factors to be considered while profiling (I mean the best practices)?

+3  A: 

Profiling basically shows you how often a given line of code is executed and how much time was spent in it (compared to other lines). This makes it easy to pinpoint the location where your code spends most of the time.

It also makes it possible to find places where your code spends much time without doing anything: this is the typical sign of a cache miss and this is where you should get active.

Usually, programs spend very much time (say, 90%) in one place. Unfortunately, finding this place without profiling isn't possible. Guesswork often goes awry. So if you optimize in the wrong place, this won't help at all: if the overall time spent in that line is only 10%, your code will only get 10% faster (at best!). If, however, you succeed in removing the call that takes 90% of the time, your programm will get ten times faster.

This, in a nutshell, is profiling.

Eclipse offers builtin profiling capabilies and I've been told that they're pretty good but since I don't know them, let someone else answer that.

Konrad Rudolph
A: 

From what little research I've done on Java profiling with Eclipse, you can use JProfiler. I never really got much further than installing it and having a quick nose around though.

Feet
A: 

YourKit is an excellent profiler for Java and will integrate nicely with Eclipse. It is definitely worth the money and generally thought to be the best Java profiler available.

Pete
+1  A: 

Konrad is right, but profiling covers other aspects of your program as well, such as memory consumption.

Hank Gay