gdc or ldc for faster programs?

Johan j at j.nl
Wed Jan 26 12:06:43 UTC 2022


On Wednesday, 26 January 2022 at 11:25:47 UTC, Iain Buclaw wrote:
> On Wednesday, 26 January 2022 at 04:28:25 UTC, Ali Çehreli 
> wrote:
>> On 1/25/22 16:15, Johan wrote:
>> > On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli
>> wrote:
>> >>
>> >> I am using compilers installed by Manjaro Linux's package
>> system:
>> >>
>> >> ldc: LDC - the LLVM D compiler (1.28.0):
>> >>   based on DMD v2.098.0 and LLVM 13.0.0
>> >>
>> >> gdc: dc (GCC) 11.1.0
>> >>
>> >> dmd: DMD64 D Compiler v2.098.1
>> >
>> > What phobos version is gdc using?
>>
>> Oh! Good question. Unfortunately, I don't think Phobos modules 
>> contain that information. The following line outputs 2076L:
>>
>> pragma(msg, __VERSION__);
>>
>> So, I guess I've been comparing apples to oranges but in this 
>> case an older gdc is doing pretty well.
>>
>
> Doubt it.  Functions such as to(), map(), etc. have pretty much 
> remained unchanged for the last 6-7 years.

The stdlib makes a huge difference in performance.
Ali's program uses string manipulation, GC, ... much more than 
to() and map().

Quick test on my M1 macbook:
LDC1.27, arm64 binary (native): ~0.83s
LDC1.21, x86_64 binary (rosetta, not native to CPU instruction 
set): ~0.75s
Couldn't test with LDC 1.6 (dlang2.076), because it is too old 
and not running on M1/Monterey (?).

-Johan



More information about the Digitalmars-d-learn mailing list