Tuesday, November 30, 2021

Delphi Compiler Speed

Since it was released in 1995, one of Delphi's defining features has been its lightning-fast compiler. And now Embarcadero is telling us that the compiler is even faster in Delphi 10.4.2 and faster still in Delphi 11.

This seems like something we can test.

In fact, some benchmarks have already been published. Jim McKeeth wrote about it when 10.4.2 was released and Darian Miller made some additional comparisons. Thanks in no small part to the contributions of Andreas Hausladen, the Delphi compiler is significantly faster than it already was. Not just under artificial conditions, but for real world applications and third party libraries.

I'm surprised more wasn't made of this at the time. 

And with all of the other compiler work going on in Delphi 11, I was curious to see if it would help or hurt performance.

The Test

The test case is simple; Measure how long it takes to compile a bunch of applications in different versions of Delphi and see if there are any major differences.

I am testing with the latest versions of Delphi 10.3.3 Rio, 10.4.2 Sydney and 11.0 Alexandria with all patches applied. In the case of Delphi 11, this includes the November patch. I have all three installed on a single virtual machine running Windows 10 Professional. The VM is hosted on a not very new computer with a mechanical hard drive, so someone with a newer machine and an SSD will probably see better times than I do. I also temporarily turned off any virus scanning so it wouldn't skew the results.

For applications, I'm using the samples that ship with Delphi, which are also available on GitHub. I included the Object Pascal samples that exist in all three versions of Delphi and excluded any that wouldn't compile. This left 262 projects. Of these, 210 are Win32, 10 are Win64 and 42 are Android. I don't have any of the other platforms installed. I didn't originally plan to test Win64 and Android but, as the saying goes, in for a penny...

I created a batch file for each version of Delphi that uses MSBuild to do a full build of each project using the Release configuration.

I love build scripts. I create one whenever I start a new project. Depending on what you're doing, it's quicker and gives you more consistent results than loading projects in the IDE. Especially if you have more than one executable or want to perform some additional tasks like running unit tests. The batch file could be as simple as this:

The output from MSBuild gives us lots of details. We're specifically interested in the compiler platform, the number of seconds taken by the compiler and the elapsed time for the entire build process.

Then it's just a matter of running the batch files, saving the results to text files and adding up all the times.

Compiler Times

These are the times reported by the compiler with no other overhead. 

I think the trend shows a fairly obvious improvement between versions.

Android compile times are long enough that the other times are difficult to see, so I broke the Windows compilers out into their own charts. And even then, the Win64 results hardly show. There probably aren't enough Win64 examples to get a good feel for its performance, but I left it in anyway.

MSBuild Times

These are the total elapsed times reported by MSBuild, which include all build activities such as file cleanup, creating resources, etc.

It looks like the Android times lost some ground in Delphi 11, but the trend still shows faster build times over all.


There are several take-aways:

  • Results vary slightly from run to run, so the margins aren't always the same, but the trend is consistent.
  • The Win64 times are especially affected by these variations and improvements may appear overly optimistic in these charts because of the small sample size.
  • Android and Win32 trends remained consistent over several runs, even with these variations.
  • I don't know what happened with Android after 10.3.3, but holy cow, what an improvement!

So yes, Delphi compile times have improved significantly in the past two releases.

Update: There was an error in adding up the times. I've posted corrected times and updated the charts.


Unknown said...

Nice, also some benchmarks about execution times would be (more) interessing.

Unknown said...

Nice ..they should devote some time to cpp vpiler also...