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:itn
- 尝试看看编译器做了什么(使用SysInternals的ProcessExplorer):显然它大部分时间运行一个名为KibitzGetOverloads的函数。但我不能对这些信息做任何事情。
EDIT, strong>
EDIT, Summary of the answers until now:
在我的案例中最好的答案:
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 < a>向delphi IDE添加项目依赖项浏览器(但不幸的是它无法显示每个分支的大小)
- Delphi单元依赖性查看器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:
- 将我的程序中的每个文件和所有组件放在一个没有子文件夹的文件夹中。 li>
- 磁盘碎片整理(我尝试使用ramdisk)
- 使用ramdisk代码源和输出文件夹。
- 关闭实时扫描防病毒
- 列出dpr文件中的所有单元,而不是依赖搜索路径。
- 使用命令行编译器dcc32或ecc32。
- Putting every files from my program and all components in one folder without subfolders.
- Defragmenting the disk (I tried with a ramdisk)
- Using a ramdisk for the code source and output folders.
- Turning off the live scanning antivirus
- Listing all the units in the dpr file instead of relying on the search path.
- Using the command line compiler dcc32 or ecc32.
不适用于我的案例:
- 避免依赖网络共享。
- 使用
- 为所有dcu使用单个文件夹(我总是这样做)
我没有尝试的东西:
- 升级
-
- 使用dcc32speed.exe
- 使用固态驱动器(我没有尝试过, ramdisk我把所有的源代码。但也许我应该在ramdisk上安装delphi)
推荐答案
在您的
使用中编译
- 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
.
尝试摆脱use子句中未使用的单元,看看它是否有所区别。
Try to get rid of unused units in your uses clause and see if it makes a difference.
这篇关于Delphi:如何组织源代码来提高编译器性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!