Why DMD is so slow?

Marco marco.falda at gmail.com
Mon Jun 2 02:48:44 PDT 2008


I have written the code reported below to test execution speed of D in Windows and I have found that the same code is about 10 times slower if compiled using DMD w.r.t. GCD: 1.9 minutes in DMD vs 1.84 seconds in GDC ! Is there perhaps something wrong? why such a difference?
Thank you.

// begin of file mandel_d1.d
/*
DMD: dmd -inline -release -O mandel_d1.d
GCD: gdc -O3 --fast-math -inline -lgphobos --expensive-optimizations mandel_d1.d
*/

import std.stdio;

int main()
{
 cdouble a, b, c, z;
 double mand_re = 0, mand_im = 0;

 for (double y = -2; y < 2; y += 0.01) {
  for (double x = -2; x < 2; x += 0.01) {
   z = (x + mand_re) + (y + mand_im) * 1i;
   c = z;
   for (int i = 0; i < 10000; i++) {
    z = z * z + c;
    if(z.re * z.re + z.im * z.im > 4.0) {
     break;
    }
   }
  }
 }
 return 0;
}
// end of file mandel_d1.d
------------------

H:\Codici\Benchmarks> ..\timethis.exe mandel_d1

TimeThis :  Command Line :  mandel_d1
TimeThis :    Start Time :  Mon Jun 02 11:28:41 2008


TimeThis :  Command Line :  mandel_d1
TimeThis :    Start Time :  Mon Jun 02 11:28:41 2008
TimeThis :      End Time :  Mon Jun 02 11:30:35 2008
TimeThis :  Elapsed Time :  00:01:54.234

H:\Codici\Benchmarks> ..\timethis mandel_gdc1

TimeThis :  Command Line :  mandel_gdc1
TimeThis :    Start Time :  Mon Jun 02 11:42:27 2008


TimeThis :  Command Line :  mandel_gdc1
TimeThis :    Start Time :  Mon Jun 02 11:42:27 2008
TimeThis :      End Time :  Mon Jun 02 11:42:29 2008
TimeThis :  Elapsed Time :  00:00:01.843
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mandel_d1.d
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20080602/1c746a3a/attachment.ksh>


More information about the Digitalmars-d-learn mailing list