Compile time optimisation for C++

Compile time optimisation for C++

Compile-time optimization is something that is usually applied last. Nevertheless, it has a direct impact on the cost savings of the development process, whether we are talking about computation power or the time of a developer.

Here I have a short list of tools that help to detect bottlenecks in compilation time:

The sequence of steps to reveal what goes wrong is simple:

  • Use the -ftime-trace Clang compiler flag to generate a JSON report for each translation unit.
  • Create an overall analysis with ClangBuildAnalyzer.
  • If needed, inspect a particular report using the Chrome utility via the address chrome://tracing/.

ClangBuildAnalyzer provides insights on the most expensive:

  • Translation units and functions to compile/optimize.
  • Headers to include.

If you need to understand what happened with a particular translation unit, you can open the corresponding generated JSON file with the Chrome trace viewer.

With this information, it's easy to detect bottlenecks in the compilation process. What you can do to eliminate these bottlenecks will be discussed in the following topics.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了