Analyze a D file for imports

anonymous via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 30 07:07:18 PDT 2015


On Tuesday, 30 June 2015 at 13:22:10 UTC, rsw0x wrote:
>> Be aware of the challenges:
>> Compiling source files separately is slower than passing them 
>> all at once to the compiler.
> this is only true for dmd

As far as I understand, the slowdown comes from parsing common 
dependencies again and again. Any compiler that doesn't cache the 
ASTs should be affected, no?

A quick check with two files that both just import std.stdio 
suggests that ldc2 behaves similar to dmd. gdc seems to do things 
differently, but it takes relatively long anyway which may 
obscure things.

$ time (dmd -c test.d test2.d)

real    0m0.028s
user    0m0.020s
sys     0m0.009s
$ time (dmd -c test.d; dmd -c test2.d)

real    0m0.059s
user    0m0.046s
sys     0m0.013s
$ time (ldc2 -c test.d test2.d)

real    0m0.046s
user    0m0.020s
sys     0m0.025s
$ time (ldc2 -c test.d; ldc2 -c test2.d)

real    0m0.090s
user    0m0.064s
sys     0m0.025s
$ time (gdc -c test.d test2.d)

real    0m0.499s
user    0m0.358s
sys     0m0.138s
$ time (gdc -c test.d; gdc -c test2.d)

real    0m0.499s
user    0m0.342s
sys     0m0.155s


More information about the Digitalmars-d mailing list