→Exercise 8: Profiling
In the other debugging exercises, we look at programs failing due to errors. Another common concern is program ''performance'' - does your program run in a reasonable time frame? This often can not be deduced by simply looking at the code. So the first step in fixing performance is identifying the location of the slowdown.
Exercise 8 in pretty straightforward with the main function calling two functions - <code>doStuff()</code> and <code>doMoreStuff()</code>. Both functions are called one after the other for two minutes. Our goal is to find which function is slower than the other. One solution a programmer may think of is to keep track of time taken by comparing values returned by [http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#currentTimeMillis%28%29 System.currentTimeMillis], but this method does not scale up for large program and requires modifications to the code. It is much more efficient and useful to use a profiler to monitor time spent in methods - which is part of the [
jvisualvm](Debugging_Exercises#Requirements ) troubleshooting tool.
'''Steps for exercise'''