June 1999

Compiler speed

Borland's compiler is famous for the speed it compiles a source file. But I wonder why C++Builder's compiling speed is so slow. Would you mind telling me how to speed up a project's build time?

Huang Xiaoyang
via email

Believe it or not, the compiler in C++Builder 4 is probably the fastest Borland C++ compiler to date. It only appears to be slower than its predecessors. With each new C++ compiler that Borland produces, the Windows operating system grows more and more complex. The result is that more APIs are added to Windows at every turn. More APIs mean more and larger header files for those APIs.

The vast majority of C++Builder's compiling time is spent compiling hundreds of thousands of lines of Windows headers. In addition to the Windows headers, the compiler also has to deal with the VCL headersat least for a standard C++Builder application. Depending on how you have your projects set up, the compiler may be compiling these headers over and over again for each unit in your project.

In addition to the header file problem is the problem of operating system performance. Obviously, Windows 95, 98, and NT are more bloated than Windows 3.1, which itself was horribly bloated when compared to the lowly DOS. These operating systems require more and more memory, and more processing power, to do their thing. This means that you must have a faster processor and more memory when running under these operating systems than you needed back in the Windows 3.1 or DOS days.

The solution to the header file problem is proper use of pre-compiled headers. Once you have pre-compiled headers properly set up, your compile times will likely be drastically reduced (maybe by as much as 75 percent). I won't try to explain how to properly set up pre-compiled headers here. Instead, I'll point you to the Web site of my fellow TeamB member, Harold Howe, which contains a detailed article on pre-compiled headers. You can find the article at

www.bcbdev.com/articles/pch.htm

The solution to the problem with Windows itself, naturally, is to be sure you have plenty of RAM, and plenty of processing power in your development machine. I wouldn't consider running today's compilers on a machine with less than 64 MB of RAM. Most of my machines have at least 128 MB of RAM. RAM is probably more important than processor speed, so if you have to choose between getting more RAM and getting a faster processor, get more RAM.

As the programming world becomes more complex, C++ compilers will appear to be slower than their predecessors, even though they're actually faster. The truth is, it's not the compiler's fault as much as it is the fault of the behemoth we call Windows.

Kent Reisdorph
TurboPower Software
KentR@TurboPower.com