在Visual Studio C ++中打印每个文件的编译时间 [英] print compilation time of each file in visual studio C++

查看:288
本文介绍了在Visual Studio C ++中打印每个文件的编译时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Visual Studio 2005项目中创建表以获取每个c ++文件的编译时间.

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

推荐答案

我正在使用Visual Studio 2010,但其他版本的Visual Studio可能具有类似的功能.在VS2010中,您可以将/Bt +添加到命令行选项,该选项将显示编译每个文件所花费的时间.因此,在项目属性的配置属性"->"C/C ++"->命令行"->其他选项"下,添加/Bt +

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+

设置/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]

有关此选项的更多信息,请访问 https://blogs.msdn.microsoft.com/vcblog/2010/04/01/vc-tip-get-detailed-build-throughput-diagnostics-using-msbuild-compiler-and-linker/ 我通过此答案找到了它 https://stackoverflow.com/a/3513043/453436

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

有很多方法可以提取时间线,具体取决于您可以使用的工具.我在结合了find,grep和perl的bash外壳下进行了此操作.下面将为您提供编译时间,以最长的时间排序.

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

这篇关于在Visual Studio C ++中打印每个文件的编译时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆