Delphi:如何组织源代码以提高编译器性能? [英] Delphi: How to organize source code to increase compiler performance?
问题描述
我正在开发一个包含大量依赖项的大型 delphi 6 项目.编译整个项目需要几分钟.一些更改后的重新编译有时会更长,因此可以更快地终止 Delphi,擦除所有 dcu 文件并重新编译所有内容.
I'm working on a large delphi 6 project with quite a lot of dependancies. It takes several minutes to compile the whole project. The recompilation after a few changes is sometimes much more longer so that it is quicker to terminate Delp erase all dcu files and recompile everything.
有没有人知道一种方法来识别,是什么让编译器越来越慢?关于如何组织代码以提高编译器性能的任何提示?
Does anyone know a way to identify, what makes the compiler slower and slower? Any tips how to organize the code to improve compiler performance?
我已经尝试过以下事情:
I have already tried following things:
- 在 dpr 中明确包含大部分单元,而不是依赖搜索路径:它没有任何改进.
- 使用命令行编译器 dcc32:它并不快.
- 尝试查看编译器做了什么(使用 SysInternals 的 ProcessExplorer):显然它大部分时间都在运行一个名为KibitzGetOverloads"的函数.但我不能用这些信息做任何事情......
编辑,到目前为止的答案摘要:
对我来说效果最好的答案:
The answer that worked best in my case:
- cnpack 中的清理未使用的单元引用"功能.它几乎自动清理了 1000 多个引用,使冷"编译快了两倍.(冷"编译 = 在编译前擦除所有 dcu 文件).它从编译器获取参考列表.因此,如果您有一些 {$IFDEF },请检查您的所有配置是否仍然可以编译.
- The function "Clean unused units references" from cnpack. It almost automatically cleaned more than 1000 references, making a "cold" compilation about twice faster. ("cold" compilation = erase all dcu files before compiling). It gets the reference list from the compiler. So if you have some {$IFDEF } check that all your configurations still compile.
接下来我想尝试:
- 手动重构单元引用(最终使用抽象类)但这是更多的工作,因为我首先需要确定问题出在哪里.一些可能有帮助的工具:
- GExperts 在delphi IDE中添加一个项目依赖浏览器(可惜不能显示每个项目的大小分支)
- Delphi Unit Dependency Viewer V1.0 做同样的事情,但没有 Delphi.它可以计算一些简单的统计数据(哪些单位被引用最多,...)
- Icarus 在 一个链接在一个答案中.
- Refactoring the unit references manually (eventually using an abstract class)
but it is much more work, since I first need to identify where the problems are. Some tools that might help:
- GExperts adds a project dependencies browser to the delphi IDE (but unfortunately it can not show the size of each branch)
- Delphi Unit Dependency Viewer V1.0 do about the same thing but without Delphi. It can calculate some simple statistics (Which units is the most referenced, ...)
- Icarus which is referenced on a link in one of the answer.
对我来说没有任何改变的事情:
Things that didn't change anything in my case:
- 将我的程序中的每个文件和所有组件放在一个文件夹中,不包含子文件夹.
- 对磁盘进行碎片整理(我尝试使用 ramdisk)
- 对代码源和输出文件夹使用 ramdisk.
- 关闭实时扫描杀毒软件
- 列出 dpr 文件中的所有单元,而不是依赖搜索路径.
- 使用命令行编译器 dcc32 或 ecc32.
不适用于我的情况的事情:
Things that didn't apply to my case:
- 避免依赖网络共享.
- 使用 DelphiSpeedUp,因为我已经有了它.
- 对所有 dcu 使用单个文件夹(我总是这样做)
我没有尝试过的事情:
- 升级到另一个 Delphi 版本.
- 使用 dcc32speed.exe
- 使用固态驱动器(我没有尝试过,但我尝试使用 ramdisk 来放置所有源代码.但也许我也应该在 ramdisk 上安装 delphi)
推荐答案
一些可能会降低编译速度的事情
Some things that could slow down the compiler
- 冗余单元在您的
uses
子句中.请参阅 this question 获取CnPack
的链接. - 没有明确地将单位添加到您的项目文件中.您似乎已经涵盖了这一点.
- 更改了编译器设置,最明显的是
include TDD32 info
.
- Redundant units in your
uses
clause. See this question for a link toCnPack
. - Not explicitly adding units to your project file. You've already seem to have covered that.
- Changed compiler settings, most notably
include TDD32 info
.
尝试去掉你的uses子句中未使用的单位,看看它是否会有所作为.
Try to get rid of unused units in your uses clause and see if it makes a difference.
这篇关于Delphi:如何组织源代码以提高编译器性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!