Skip to content, Skip to search


Debugging Exercises

1 byte added, 07:57, 17 December 2015
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 [ 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) |jvisualvm]] troubleshooting tool.
'''Steps for exercise'''
Bureaucrat, emailconfirmed, incoming, administrator, uploaders