Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java profiling - How reliable are the values it gives?

Tags:

java

text

markup

I am working on a simple text markup Java Library which should be, amongst other requirements, fast.

For that purpose, I did some profiling, but the results give me worse numbers that are then measured when running in non-profile mode.

So my question is - how much reliable is the profiling? Does that give just an informational ratio of the time spent in methods? Does that take JIT compiler into account, or is the profiling mode only interpreted? I use NetBeans Profiler and Sun JDK 1.6.

Thanks.

like image 368
Ondra Žižka Avatar asked Jan 17 '10 15:01

Ondra Žižka


1 Answers

When running profiling, you'll always incur a performance penalty as something has to measure the start/stop time of the methods, keep track of the objects of the heap (for memory profiling), so there is a management overhead.

However, it will give you clear pointers to find out where bottlenecks are. I tend to look for the methods where the most cumulative time is spent and check whether optimisations can be made. It is also useful to determine whether methods are called unnecessarily.

With methods that are very small, take the profile results with a pinch of salt, sometimes the process of measuring can take more time than the method call itself and skew the results (it might appear that a small, often-called method has more of a performance impact).

Hope that helps.

like image 157
beny23 Avatar answered Oct 06 '22 23:10

beny23