1

我试图在我的解决方案中使用 PCH 来缩短编译时间,但令人难以置信的是,没有. 这是统计数据:

在 i7 上运行 8GB 的​​ Windows 7 x64

示例项目:235 个 cpp 文件,总共 4.5 MB 源代码(使用 MFC)

使用 PCH 需要 13:55 分钟

没有 PCH 需要 6:15 分钟

我很确定我正确使用它们,项目设置为在项目级别使用预编译头文件,并且 StdAfx.cpp 设置为通过 StdAfx.h 创建预编译头文件

所有标准#includes都放在StdAfx.h中,所有cpp文件都以

#include "StdAfx.h"

我无法理解它。任何人都知道会发生什么,或者我什至会如何开始尝试解决它?

4

1 回答 1

0

So I worked around this eventually. My solution has a structure as follows:

C:\Data\Bus\VS\Projects\Solution.sln
C:\Data\Bus\VS\Projects\Proj1\
C:\Data\Bus\VS\Projects\Proj2\
C:\Data\Bus\VS\Projects\Proj3\
etc

Because these are used all the time, I have mapped a drive letter:

P = C:\Data\Bus\VS\Projects\

to this area for easier access to the solution using the following:

P:\Solution.sln
P:\Proj1\
P:\Proj2\
P:\Proj3\

I have found that VS2008 does not like opening the solution via the mapped drive letter (P), this is where the slower build with PCH occurs.

But if I open with a full path directly to the C drive, the PCH gives excellent speed advantage as expected.

Anyone have any idea about this? I can only think that the drive aliasing is giving VS the wrong impression that the PCH is always out of date, and so it rebuilds it with every file. Very mysterious.

于 2012-05-31T08:08:09.083 回答