April 7, 2006

Can we trust the profiling tools?

Can we trust the profiling tools? Plain and simple: Not if you don’t know what you are doing. Running the tool is not sufficient.

Know that there are multiple things that can affect the outcome of the profiling exercise, timings are the last thing you want to trust. Lets look at the prominent reasons:

1. Operating system – Various OS have their own ways of prioritizing the threads of execution, hence these priorities will impact your results. Specially in Windows environment, default setting gives more time to processes running on foreground.

2. Cache – Most developers profile their code by restating the application server to ensure these start with minimum threads, however it affects the systems which use cashing. We must ensure the consistent environment to profile for improvements.

The most reliable way to check the timing will be to use System.currentTimeMillis() in the code that needs to be tested. Caution – use judicially.

Last words… know your profiling tool before you start the process of profiling and fixing the code. Happy coding!