Inherent code performance advantages of D over C?

Marco Leise Marco.Leise at gmx.de
Tue Dec 10 15:23:59 PST 2013


Am Tue, 10 Dec 2013 22:16:25 +0100
schrieb "Adam D. Ruppe" <destructionator at gmail.com>:

> On Tuesday, 10 December 2013 at 21:05:53 UTC, Walter Bright wrote:
> > At the least, it'll compile a lot faster!
> 
> Small C programs compile a *lot* faster than small D programs 
> that use Phobos.
> 
> import std.stdio; == add half a second to your compile time.
> 
> $ time dmd hellod.d
> 
> real    0m0.780s # YIKES!
> user    0m0.649s
> sys     0m0.102s
> 
> $ time gcc helloc.c
> 
> real    0m0.148s # not bad
> user    0m0.095s
> sys     0m0.039s
> 
> 
> yikes, even doing printf in D is slow nowadays
> 
> $ time dmd hellod.d
> 
> real    0m0.290s # good but not great
> user    0m0.212s
> sys     0m0.058s
> 
> 
> 
> Larger D programs do better, of course, at least if you compile 
> all the files at once (and don't use so much CTFE that it starts 
> thrashing the swap file).

Isn't it fairer to compile only (-c):

dmd -c std_stdio.d  0,30s user 0,07s system 99% cpu 0,374 total
dmd -c printf.d     0,00s user 0,00s system 87% cpu 0,008 total
gcc -c printf.c     0,02s user 0,01s system 93% cpu 0,031 total

-- 
Marco



More information about the Digitalmars-d mailing list