D has now surpassed C++ in overall performance

janderson askme at me.com
Fri Feb 2 08:42:39 PST 2007


Knud Soerensen wrote:
> On Thu, 01 Feb 2007 18:30:55 -0800, janderson wrote:
> 
>> John wrote:
>>> D has now surpassed C++ in overall performance at the "Computer Language Shootout" website. This change came about with the upgrade to 1.004 from 1.000 (I'm guessing because of the new GC).   
>>>
>>> http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all&calc=Calculate&xfullcpu=1&xmem=1&xloc=0&binarytrees=1&chameneos=1&message=1&fannkuch=1&fasta=1&knucleotide=1&mandelbrot=1&meteor=0&nbody=1&nsieve=1&nsievebits=1&partialsums=1&pidigits=1&recursive=1&regexdna=1&revcomp=1&spectralnorm=1&hello=0&sumcol=1
>>
>> Only if you take memory into account.  CPU performance is still not up 
>> to par.
>>
>> The recursive and the mandelbrot are the biggest performance eaters. 
>> Recursive is the same as gcc so it must be a compiler thing I guess.
>>
>> -Joel
> 
> Well the gcc mandelbrot use sse commands for fast computations
> maybe when D get vectorization this will change.
> 
> I noticed that gcc recursive uses
> 
> template < class N >
> N Fib(N n)
> {
>    return __builtin_expect(n < 2, 0) ? 1 : Fib(n - 2) + Fib(n - 1);
> }
> 

I would argue that that shouldn't be allowed.

> while D uses
> template Fib(T)
> {
>     T Fib(T n)
>     {
>         if(n < 2) return 1;
>         else return Fib(n-2) + Fib(n-1);
>     }
> }
> 
> I remember a while back I notice that there is a speed difference 
> between using x<y ? a:b; and using if (x<y) a; else b; 
> maybe they are not optimized the same way ???

Good point.  It should be something optimized by the compiler.



More information about the Digitalmars-d-announce mailing list