D speed compared to C++

Sean Kelly sean at invisibleduck.org
Tue Mar 18 14:11:51 PDT 2008


== Quote from BCS (BCS at pathlink.com)'s article
> Matthew Allen wrote:
> >
> > An example of a simple loop test I ran is as follows:
> >
> > DWORD start = timeGetTime();
> > 	int i,j,k;
> > 	float dx=0;
> >     for(i=0; i<1000;i++)
> >         for(j=0; j<1000;j++)
> >             for(k=0; k<10; k++)
> >                 {
> >                      dx++;
> >                 }
> >     DWORD end = timeGetTime();
> >
> > In C++ int and doubles. The C++ came back with a time of 15ms, and D came back with 45ms.
> first of all what C++ compiler? the best for testing would be DMC as
> that removes the back end differences.
> Second how many test runs was that over?
> third, try it with doubles (64bit reals) in both programs as the
> different conversions might be making a difference.
> Another thing that might mask some stuff is start up time. Try running
> the test loops in another loop and spit out sequential times. I have
> seen large (2x - 3x) differences in the first run of a test vs. later
> runs.

D apps also have more going on in the application initialization phase than C++ apps.  For a real
apples-apples comparison, you might want to consider using Tango with the "stub" GC plugged in.
That just calls malloc/free and has no initialization cost, at the expense of no actual garbage collection.
I'll have to check whether the stub GC compiles with the latest Tango--it's been a while since I used it.


Sean



More information about the Digitalmars-d mailing list