ashokgelal
ashokgelal

Reputation: 81528

What is profiling all about and how can I profile my Java program?

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)?

Upvotes: 5

Views: 3684

Answers (4)

Hank Gay
Hank Gay

Reputation: 71939

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

Upvotes: 2

Peter
Peter

Reputation: 29837

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.

Upvotes: 0

Feet
Feet

Reputation: 2587

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.

Upvotes: 0

Konrad Rudolph
Konrad Rudolph

Reputation: 545508

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.

Upvotes: 8

Related Questions