dmd -run speed trends

Siarhei Siamashka siarhei.siamashka at gmail.com
Sat Dec 16 23:35:12 UTC 2023


On Saturday, 16 December 2023 at 03:26:16 UTC, Walter Bright 
wrote:
> On 12/7/2023 8:32 AM, Witold Baryluk wrote:
>> I do not use `dmd -run` too often, but recently was checking 
>> out Nim language, and they also do have run option, plus 
>> pretty fast compiler, so checked it out.
>
> If you use `rdmd`, it caches the generated executable, so 
> should be mucho faster for the 1+nth iterations.

Running the program from source in a script-like fashion is a 
very common standard feature for compilers. Also supported by at 
least Nim, Go and Crystal. And being a standard feature, fair 
apples-to-apples comparisons can be done for different 
programming languages.

Out-of-the-box experience with the latest version of DMD on a 
Linux system typically involves something like downloading a 
pre-build 
https://downloads.dlang.org/releases/2.x/2.106.0/dmd.2.106.0.linux.tar.xz binary release tarball. See the https://forum.dlang.org/thread/dqaiyvgncpuwmmicsjyk@forum.dlang.org thread for a feedback from one of the new onboarded users.

There's the `rdmd` tool bundled there, many new users will notice 
it and take into use. The documentation at 
https://dlang.org/dmd-linux.html describes it as "D build tool 
for script-like D code execution". And it even has its own page 
here: https://dlang.org/rdmd.html

I guess, you see what is coming next. DMD is widely advertised as 
a fast compiler. The users will judge its performance using the 
`rdmd` tool. Because again, it's a pretty standard functionality, 
provided by many programming languages in one way or another. 
Comparison between DMD 2.106.0, Crystal 1.10.1, Nim 1.6.14 and Go 
1.21.4 on my computer (x86-64 Linux) using the test program from 
the first post in this thread:

| test                                                       | 
normal | cached |
|------------------------------------------------------------|--------|--------|
| echo " " >> bench.cr && time crystal bench.cr              | 
1.81s  |  1.81s |
| echo " " >> bench_writefln.d && time rdmd bench_writefln.d | 
1.22s  |  0.01s |
| echo " " >> bench.nim && time nim --hints:off r bench.nim  | 
1.05s  |  0.18s |
| echo " " >> bench.cr && time crystal i bench.cr            | 
0.91s  |  0.91s |
| echo " " >> bench_writefln.d && time dub bench_writefln.d  | 
0.84s  |  0.03s |
| echo " " >> bench_writeln.d && time rdmd bench_writeln.d   | 
0.59s  |  0.01s |
| echo " " >> bench_writeln.d && time dub bench_writeln.d    | 
0.49s  |  0.03s |
| echo " " >> bench.go && time go run bench.go               | 
0.15s  |  0.13s |

The cached column shows the time without the `echo` part (Crystal 
apparently doesn't implement caching). That's what any normal 
user would see if they compare compilers out of the box in the 
most straightforward manner without tweaking anything. I also 
added results for `dub` (with the `/+dub.sdl:+/` boilerplate line 
added) to compare them against `rdmd`.


More information about the Digitalmars-d mailing list