如何提高Visual C ++编译时间? [英] How to improve Visual C++ compilation times?

查看:133
本文介绍了如何提高Visual C ++编译时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在每次提交时在buildbot中编译2个C ++项目。两者都是大约1000个文件,一个是100 kloc,另一个是170 kloc。编译时间与gcc(4.4)和Visual C ++(2008)非常不同。



一个项目的Visual C ++编译需要20分钟。他们不能利用多个核心,因为一个项目依赖于另一个。最后,在Debug和Release中对两个项目的完整编译,32位和64位需要超过2.5个小时。



gcc编译一个项目在4分钟。它可以并行在4个核心,并需要大约1分10秒。所有8个版本的4个版本(Debug / Release,32/64位)的2个项目都是在不到10分钟内编译。



Visual C ++编译时间?它们基本上慢了5倍。



编译C ++ kloc的平均时间是多少? Mine是7 s / kloc与vc ++和1.4 s / kloc与gcc。



可以做任何事情以加快Visual C ++的编译时间?

$减慢VC ++编译器的一件事是如果你有一个头文件初始化非三元组的具体实例 const 值类型。您可能会看到类型 std :: string 或GUID的常量发生。它会影响编译和链接时间。



对于单个dll,这会导致10倍的减速。如果将它们放在预编译的头文件中,或者只是在头中声明它们并在cpp文件中初始化它们,这将有所帮助。



请查看病毒扫描程序,并确保实验预编译头,没有它,你不会看到VC ++的最佳状态。



是的,并确保%TMP%文件夹在与您的构建文件写入的分区相同的分区上,因为VC ++生成temp文件并稍后移动它们。


I am compiling 2 C++ projects in a buildbot, on each commit. Both are around 1000 files, one is 100 kloc, the other 170 kloc. Compilation times are very different from gcc (4.4) to Visual C++ (2008).

Visual C++ compilations for one project take in the 20 minutes. They cannot take advantage of the multiple cores because a project depend on the other. In the end, a full compilation of both projects in Debug and Release, in 32 and 64 bits takes more than 2 1/2 hours.

gcc compilations for one project take in the 4 minutes. It can be parallelized on the 4 cores and takes around 1 min 10 secs. All 8 builds for 4 versions (Debug/Release, 32/64 bits) of the 2 projects are compiled in less than 10 minutes.

What is happening with Visual C++ compilation times? They are basically 5 times slower.

What is the average time that can be expected to compile a C++ kloc? Mine are 7 s/kloc with vc++ and 1.4 s/kloc with gcc.

Can anything be done to speed-up compilation times on Visual C++?

解决方案

One thing that slows down the VC++ compiler is if you have a header file that initializes concrete instances of non-trival const value types. You may see this happen with constants of type std::string or GUIDs. It affects both compilation and link time.

For a single dll, this caused a 10x slowdown. It helps if you put them in a precompiled header file, or, just declare them in a header and initialize them in a cpp file.

Do take a look into the virus scanner, and be sure to experiment with precompiled headers, without it you won't see VC++ at its best.

Oh yeah, and make sure the %TMP% folder is on the same partition as where your build is written to, as VC++ makes temp files and moves them later.

这篇关于如何提高Visual C ++编译时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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