6 Finding hidden issues 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 these tools 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 finding out what part of 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)

6.1 Sampling to observe executing code

6.2 Profiling to learn how many times a method is executed

6.3 Using a profiler to identify SQL queries an app executes

6.3.1 Using a profiler to retrieve SQL queries not generated by a framework

6.3.2 Using the profiler to get the SQL queries generated by a framework

6.3.3 Using the profiler to get programmatically generated SQL queries

6.4 Summary