It is not wise to optimize code without benchmarking it. Similarly, it is not wise to investigate and improve C++ build times without even knowing the build times.
Enabling Build Times
To turn on the display of build time in Visual C++, go to Tools → Options → Projects and Solutions → VC++ Project Settings. Set the Build Timing option to Yes. Once turned on, Visual C++ will display the build time after a build in the output window.
Visual C++ 2008
On Visual C++ 2008 and older versions, it is displayed simply like this:
Build Time 0:20
Visual C++ 2010
The Build Timing output has undergone major changes in Visual C++ 2010, which displays all kinds of detailed diagnostics. But, by default it does not even display the total build time! Very ironic, I know! 😊
To be able to see the total build time in Visual C++ 2010, go to Tools → Options → Projects and Solutions → Build and Run. Set the MSBuild project build output verbosity to Normal. (You could set it higher to Detailed or Diagnostic too.) After setting this, look for the build time at the bottom of the output window after a build:
Build succeeded. Time Elapsed 00:00:01.43