print compilation time of each file in visual studio C++ - visual-studio

How can i create a table to get compilation time of each c++ file in visual studio 2005 project.

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

"Tools" -> "Options" -> "Projects and Solutions" -> "VC++ Project Settings"
Tick "Build Timing".

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:
CreateProcess on the command line compiler, redirecting stdout to a pipe
Read from the pipe, looking for source file names
Each time a source file name is seen, note the current timestamp
When the pipe is closed, print out the times taken for each file build
While this approach could be developed in C++, it would likely be easier to use a tool such as Perl to implement it.

Related

Faster way to compare changes made in Changeset for TFS Source Control

IF I have a large changeset and want to be able to compare all changes before checking them in, is there a faster way than manually clicking compare to latest on every file? I have something like 900 files I changed, and that seems veryinefficient. There has to be a way to open all files in compare and be able to click close or ignore on each file one by one.
Best way to compare large changeset vs existing code?
Try this:
Open a Visual Studio Command Prompt (All Programs | Visual studio | Visual Studio Tools | Developer Command Prompt
(this is just a normal command prompt but with some extra env variables set, and with the visual studio tools in your path).
use the cd command to switch directory to the root directory that your project is in on your local disk that you want to compare: example: cd \MyProjects\TheProject
execute this command:
tf folderdiff . $/The/Tfs/Folder/Path/To/Corresponding/ProjectDir/On/Server /recursive /view:different
(there is a space between the "folderdiff" and the ".", and another space between the "." and the $/ The "." just says "use the current local path (you should be sitting on it). Being on the current path also gives the TFS command the context that it needs so that it knows how to connect to your TFS server, and which team project and collection to use.

How to make MSBuild print output from a custom tool?

I have a project, which use a .rules file to build some non-c++ sources. How to make MSBuild print diagnostic output from this tool? -- Precisely cerr stream.
(I silently presume, the M$ team have not reached that level of insanity, to give the custom building tools functionality without possibility to print errors from them.)
I've actually noticed you marked question with label visual-studio-2008. I guess it means your custom build tool processes non cpp files in vc2008 project? If so, I think it is not built by msbuild but with vcbuild.
In this case try to add echo on in front of command executed by custom tool.
Vcbuild creates batch files in %temp% that first line contains #echo off and then it is executed. So if you add echo on you should see complete output in output window including command line used for command execution.

debugging with visual studio using redirected standard input

I am debugging c++ console application with Visual studio. I exhausted of inserting the same input every time I debug this program. I would like to use the same input more times.
I do this without debugging in command line with command: Program.exe < 1.in
Is it possible to use debugging with standard input redirected from file???
I already tried looking in to procejt properties. I tried setting Command to $(TargetPath) < 1.in instead of $(TargetPath).
I also tried setting Command Arguments to < 1.in. Niether of these method worked.
I am using Visual Studio 2012. But this is probably same in all versions of studio.
This is a supported debugging scenario. You do have to make sure that the debugger can find the file. Leave the Command setting at $(TargetPath). A possible value for the Command Arguments setting is:
< "$(ProjectDir)test.txt"
if the input file "test.txt" is located in the project directory. Or type the full path of the file to be sure. The MSDN article that describes this feature is available here.
I just create a file called stdin.txt in the project
1) set the Build Action to Content
2) Copy to Ouput Directory: Copy if newer
Then when you build stdin.txt is copied to the same folder as the executable.
Then in project properties debug|command line arguements enter the following
< stdin.txt
There is no need to use a path macro
If you don't want to mess with the the path you can add a new file with a right click on the source files folder in the solution explorer and then paste to it the content from the wanted file. And then change the command argument to the new file name.

Finding build output in Visual Studio 6 (visual basic)

I realize this is going to be an exotic question, but I just can't find the answer.
I'm trying to fix up and enhance an old visual basic-based application.
My problem is: where is the output directory with the compiled binaries?
Thanks.
If some clarification is needed, please ask.
In the .VBP, if there is a line specifying the path like this
Path32="C:\"
Then the resulting EXE will be built at that location. Otherwise, it will be built in the same directory as the .VBP file. The path can be relational as well and may not be a fully qualified path.
I think you want the /outdir switch. This overrides the Path32 setting in the Project file.
VB6[.EXE] [[{/run | /r}] | [/runexit] | [{/make | /m}] projectname]
[/out filename] [/outdir path] [/d const=value{[:constN=valueN]}]
[/mdi | /sdi] [{/cmd argument | /c argument}]
Options:
/run or /r projectname Tells Visual Basic to compile projectname and run it,
using the arguments stored in the Command Line
Arguments field of the Make tab of the Project
Properties dialog box.
/runexit projectname Tells Visual Basic to compile projectname and run it.
Visual Basic will exit when the project returns to
design mode.
/make or /m projectname Tells Visual Basic to compile projectname and make an
executable file from it, using the existing settings
stored in the project file.
/out filename Specifies a file to receive errors when you build using
/m or /runexit. If you do not use /out, command line
bild errors are displayed in a message box.
/outdir path Specifies a directory path to place all output files in
when using /make. This path must already exist.
/d or /D const=value... Tells Visual Basic which values to use for conditional
compilation constants when making an .EXE or ActiveX
component with the /make switch. Separate multiple
constants with colons.
/cmd or /c argument Specifies a command string to be passed to the Command$
function. When used, it must be the last switch on the
command line.
/mdi or /sdi Changes the Visual Basic environment to either Single
Document Interface (SDI) or Multiple Document Interface
(MDI) mode. Visual Basic remains in this mode until
you change it.
/? Displays a list of valid command line switches.
You may use a group name in place of projectname in any of the above switches.
Works fine here.
There is no equivalent 'bin/lib' output directory for VB6. When you compile a VB6 project, the default is to compile to the same folder as the project (vbp file). It is also possible to compile to any other folder available to the user.

Get all files checked out by a user using the Visual Source Safe command line application SS.exe

We currently use VSS 6, this is not going to change I am afraid.
I am attempting to write a script that will allow a user to quickly copy all files that they have checked out to another directory tree. In order to do this I need to get a list of all the files that the user has checked out, and the directory that the file is checked out to. This is easy enough to do using status search in the GUI. But I need a way of doing it from the command line utility ss.exe.
Two links that may be of use:
VSS CommandLine Commands
VSS CommandLine Options
To expand on Panos reply
ss.exe Status $/ -R -U<Username>
Will get you the files of a particular user.
From the command line:
cd C:\Program Files\Microsoft Visual SourceSafe
SET SSDIR=<path to folder containing srcsafe.ini>
ss Status $/ -R -U<username> > checked-out-by-username.txt
And then check the contents of checked-out-by-username.txt for your check-outs.
For example:
My srcsafe.ini was in C:\Program Files\Microsoft Visual SourceSafe\MasterDatabase. And my username was bpaetzke.
So, my command line looked like this:
cd C:\Program Files\Microsoft Visual SourceSafe
SET SSDIR=MasterDatabase
ss Status $/ -R -Ubpaetzke > checked-out-by-bpaetzke.txt
If you want to get all users' check-outs, remove the -U and give the output file a generic name.
Other command line info:
commands
options
I came here looking for the same thing but with Visual Source Safe version >= 8.0, the command doesn't seem to work for me, instead I found an easier way to search using menu:
View -> Search -> Status Search
There select the option to search by user and specify the user name
See here for the command line usage of Status command. The command
ss.exe Status $/ -R -U
shows every file in the system that is checked out by the current user.

Resources