D 50% slower than C++. What I'm doing wrong?

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Sat Apr 14 22:45:37 PDT 2012


On 15/04/12 05:41, jerro wrote:
> I have never seen anything like that. Usually the minimal time to run a D
> program is something like:
>
> j at debian:~$ time ./hello
> Hello world!
>
> real 0m0.001s
> user 0m0.000s
> sys 0m0.000s

Yea, my experience too in general.  I can't remember exactly what I was testing 
but if it's what I think it was (and have just retested:-), the difference may 
have been less pronounced (maybe 0.080s for D compared to 0.004 for C++) and 
that would have been due to not enabling optimizations for D.

I have another pair of stupid D-vs.-C++ speed-test files where with 
optimizations engaged, D beats C++: the dominant factor is lots of output to 
console, so I guess this is D's writeln() beating C++'s cout.

>> What really amazes me is the difference between g++, DMD and GDC in size of
>> the executable binary. 100 orders of magnitude!
>
> With GDC those flags(for gdmd):
>
> -fdata-sections -ffunction-sections -L--gc-sections -L-l
>
> help a lot if you want to reduce a size of executable. Besides, this overhead is
> the standard library and runtime and won't be much larger in larger programs.

Ahh! I hadn't realized that the libphobos package on Ubuntu didn't install a 
compiled version of the library.  (DMD does.)


More information about the Digitalmars-d-learn mailing list