- Hands-On High Performance Programming with Qt 5
- Marek Krajewski
- 185字
- 2021-07-02 13:53:50
Poor man's sampling technique
I call that technique the poor man's sampling technique. It is really simple. In its most basic form, you run a program in a debugger, stop it several times, and examine the call stack of the randomly chosen breaks. The idea is (as with sampling profilers) that the most-used function will show most often in the stack trace. Simple as it is, this quick technique will sometimes will give us enough information to diagnose the problem.
Unexpectedly, this can be done most elegantly with the Process Explorer. We just need to get to the Threads tab, double-click on a selected row, and the stack trace of this thread will be shown, as in the following screenshot:
Besides that, the Threads tab gives us an overview of the single thread's memory usage, thread's creation and deletion (the color red signifies deletion, green creation), and the changing workload.
In the following sections, we will at last show how to use some more specialized tools, and how to quickly locate the problematic spots in an application that's not working very well.