将代码拆分成几个.cpps会减少编译时间? [英] Will splitting code into several .cpps decrease compilation time?

查看:166
本文介绍了将代码拆分成几个.cpps会减少编译时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设a有一个相当复杂的类,我正在工作。一半的方法已经完成和测试,但我仍然devolping的另一半。如果我把完成的代码放在一个cpp和其余的,在另一个,Visual Studio(或任何其他IDE)编译更快,当我只更改工作进行中cpp的代码?

Suppose a have a fairly complex class I'm working on. Half the methods are done and tested, but I'm still devolping the other half. If I put the finished code in one cpp and the rest in another, will Visual Studio (or any other IDE for that matter) compile faster when I only change code that's in the "work-in-progress" cpp?

谢谢!

推荐答案

对于一个非常大的项目,链接时间通常比编译单个文件的时间贵得多。在我们的工作代码库(基于虚幻引擎的游戏)中,我们实际上发现包含许多其他文件的bulk.cpp文件(有效地减少了翻译单元)大大减少了周转时间。

It really depends. For a very large project, link time can often be considerably more expensive than the time to compile a single file. In our codebase at work (a game based on the Unreal Engine) we actually found that making "bulk.cpp" files that include many other files (effectively fewer translation units) decreases the turn around time significantly.

即使单个编译时间增加了,整个编译时间(完全重建)和链接时间(即使对于一个小的变化)也会大幅减少。

Even though individual compile time for a small change was increased, overall compile time (full rebuild) and link time (which happens even for a small change) both decreased dramatically.

这篇关于将代码拆分成几个.cpps会减少编译时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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