Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling and Optimizing Compilation

The compilation time of my project is quite long and I'd like to reduce this as much as possible. However, right now I'm just browsing around my project and try to remove compilation heavy stuff on pure intuition.

I would like to be able to profile my compilation on some level which would give me useful information which I can use to identify what is taking most of my compilation time.

I have tried enabling "Build Timing" in Visual Studio but that does not give me more information than timing of the different tasks the compiler is performing, knowing that most time is spent in "CL" is not very helpful.

Is there any way to profile compilation at a lower level such as line or file timing?

like image 698
ronag Avatar asked Mar 09 '11 21:03

ronag


People also ask

What does an optimizing compiler do?

In computing, an optimizing compiler is a compiler that tries to minimize or maximize some attributes of an executable computer program. Common requirements are to minimize a program's execution time, memory footprint, storage size, and power consumption (the last three being popular for portable computers).

What is optimizing compiler design?

The code optimization in the synthesis phase is a program transformation technique, which tries to improve the intermediate code by making it consume fewer resources (i.e. CPU, Memory) so that faster-running machine code will result.

Why do we need code optimization phase in the compilation process?

i.e. code optimization allows consumption of fewer resources. (i.e. CPU, Memory), which results in faster running machine code. Optimized code also uses memory efficiently. The optimization must be correct, it must not, in any way, change the meaning of the program.

What are code optimization techniques?

Code Optimization Techniques. Rearranges the program code to minimize branching logic and to combine physically separate blocks of code. If variables used in a computation within a loop are not altered within the loop, the calculation can be performed outside of the loop and the results used within the loop.


1 Answers

I have no compilation profiling advice to offer. However, here's a couple of tips to reduce compilation time:

  • Use Forward declaration in header file as much as possible

    In C++, classes can be forward-declared if you only need to use the pointer-to-that-class type (since all object pointers are the same size, and this is what the compiler cares about). (source: http://en.wikipedia.org/wiki/Forward_declaration)

  • Also, using the Pimpl idiom will help you a lot by allowing the compiler to recompile only the part you've modified. http://en.wikipedia.org/wiki/Opaque_pointer

  • Avoid catch-all include file that contains all the include file of a library and only include the headers you actually need.

like image 104
Jean-Philippe Jodoin Avatar answered Oct 02 '22 04:10

Jean-Philippe Jodoin