Reputation:
How can i create a table to get compilation time of each c++ file in visual studio 2005 project.
Upvotes: 13
Views: 4077
Reputation: 2976
I am using Visual Studio 2010 but other versions of Visual Studio may have something similar. In VS2010 you may add to the command line options /Bt+ which prints the time taken to compile each file. So in a project properties under "Configuration Properties" -> "C/C++" -> "Command Line" -> "Additional Options" add /Bt+
Setting the /Bt+ option results in the output (which is recorded in the log file) lines like the following:
time(c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\c1.dll)=0.05110s < 25394686804 - 25394831194 > BB [C:\not-important\nlopt-2.4.2\direct\DIRect.c]
More information on this option at https://blogs.msdn.microsoft.com/vcblog/2010/04/01/vc-tip-get-detailed-build-throughput-diagnostics-using-msbuild-compiler-and-linker/ which I found thanks to this answer https://stackoverflow.com/a/3513043/453436
There are plenty of ways to extract the time lines depending on what tools you have available to you. I did it under a bash shell with a combination of find, grep and perl. The following will give you the compilation time sorted with longest first.
find . -name '*.log' | xargs grep time | perl -ne '$_ =~ /=(.*?)s.*\[(.*)\]/; print "$1 $2\n";' |sort -rn
Upvotes: 15
Reputation: 992707
It's been a while since I've used that version of the compiler, but I recall it prints the name of the file it's compiling to the console (when you use the command line build). If that's the case, then you can write a program that does the following:
While this approach could be developed in C++, it would likely be easier to use a tool such as Perl to implement it.
Upvotes: 0
Reputation: 84792
"Tools" -> "Options" -> "Projects and Solutions" -> "VC++ Project Settings"
Tick "Build Timing".
Upvotes: 2