6 Finding hidden problems using profiling techniques
This chapter covers
- Sampling an app’s execution to find the currently executing methods
 - Observing execution times
 - Identifying SQL queries the app executes
 
In chapter 5, I said a profiler is a powerful tool that can show you a path when all the lights have gone out. But we discussed only a small part of the profiler’s capabilities. A profiler offers powerful tools for investigating an app’s execution, and learning to use them properly can help you in many scenarios.
In many cases, I have had to evaluate or investigate app executions for codebases I could barely read—old apps with poorly modeled code design, which some companies kept hidden in a wardrobe. In such cases, the profiler was the only efficient way to find what was executing when a specific capability was triggered. Now you can see why I compared a profiler with the light of Eärendil: as Galadriel says, it really was a light in many dark places where all the other lights were out.
In this chapter, we will analyze three investigation techniques through profiling, which I consider extremely valuable:
- Sampling for detecting the part an app’s code executes
 - Profiling the execution (also called instrumentation) to identify wrong behavior and badly performing code that can be optimized
 - Profiling the app to identify SQL queries it uses to communicate with a database management system (DBMS)