- Hands-On High Performance Programming with Qt 5
- Marek Krajewski
- 171字
- 2021-07-02 13:53:53
Manual instrumentation
As already stated, using the Chrome tracing tab (chrome://tracing/) as a performance visualizer is a popular technique. We could either whip up a set of instrumentation functions by ourselves or, preferably, find an existing, already-implemented library. And, indeed, there are such libraries in the wild, and one of them is SPDR (https://github.com/uucidl/uu.spdr); another example is Minitrace (https://github.com/hrydgard/minitrace). In the following screenshot, you'll see an example showing Chrome's own performance trace:
As you can see, Chrome displays performance data in the form of flame graphs. This is a relatively recent visualization introduced by Linux perftools author, Brendan Gregg. A flame graph shows nested function calls in the vertical direction and the time flow in the horizontal direction. It is very suitable for visualizing deep function-call hierarchies. Upon clicking each rectangle in the graph, its performance data will be shown. We can use the previously mentioned projects to generate our custom call hierarchy and performance graphs in that format and view them with Chrome. That would look very professional!