Hands-On High Performance Programming with Qt 5
上QQ阅读APP看书,第一时间看更新

Program profiling tools

There are no CPU profilers supported and integrated in Qt Creator on Windows. We will thus have to fall back on a profiler started in a standalone manner. 

Very Sleepy (http://www.codersnotes.com/sleepy/) is a simple and popular open source profiler. Admittedly, its UI is rather spartan but is probably sufficient for many non-graphic applications. In the following screenshot, we can see the results of a CPU profiling run with one of Qt's demo programs:

There is another open source profiler that could be used: MD's CodeXL profiler. It has a much richer UI than Very Sleepy, and is in fact much more than a CPU profiler. It supports GPU debugging, frame analysis, GPU profiling, shader analysis, and power profiling. In the following screenshot, you can see the results of a CPU profiling run with one of the contained demo programs displayed in its UI:

The screenshot shows the call graph visualization, where clicking on the functions with most samples will take us down along the hot path, but there is also a list of most-sampled functions and modules in separate tabs.

Microsoft's Visual Studio contains its own integrated profiler even in the Community Edition, but we decided on Qt Creator as the IDE, so we won't discuss that. Luke Stackwalker (http://lukestackwalker.sourceforge.net/) has a much better UI than Very Sleepy and is available for Windows, but unfortunately it only supports Microsoft compiler's debug information format. Because we are using MinGW's GNU compiler, we must dispense with it. The same pertains to the open source Orbit ProfilerGoogle's perftools suite supports Windows, and it contains its own sampling profiler, but the profiler is not available on Windows.