dmd-x64

alkor alor at au.ru
Wed Dec 23 06:15:54 PST 2009


oh no - both files aren't stripped

after strip a difference is 2,3 times 
$ strip main-gdc main-dmd
$ ls -l main-dmd main-gdc
-rwxr-xr-x 1 alkor alkor  65088 Dec 23 16:44 main-dmd
-rwxr-xr-x 1 alkor alkor 155784 Dec 23 16:44 main-gdc

and main-gdc required libgcc_s.so.1

$ ldd main-gdc
        linux-gate.so.1 =>  (0xffffe000)
        libm.so.6 => /lib/libm.so.6 (0xb7ee7000)
        libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0xb7edc000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb7ec4000)
        libc.so.6 => /lib/libc.so.6 (0xb7d89000)
        /lib/ld-linux.so.2 (0xb7f2d000)

--- the next test - math performance ---
module test.performance;

import std.stdio, std.random;
const int MAX = 10000000;
int main () {
    int[] a = new int[MAX];
    int[] b = new int[MAX];
    double[] c = new double[MAX];

    for (auto i=0;  i< MAX; i++) {
	a[i] = i | 0xa1c0;
	b[i] = i | 0xbadbad;
    }

    for (auto i=0;  i< MAX; i++) {
	c[i] = (a[i] & 0x10) ? cast(double)a[i] * b[i] * b[i] : cast(double)a[i] * a[i] * b[i];
    }
    writefln("init a[9555000] 0x%08X", a[9555000]);
    writefln("init b[9555000] 0x%08X", b[9555000]);
    writefln("init b[9555000] %f", c[9555000]);
    return 0;
}
$ dmd -O -release -oftest-dmd test-performance.d && strip test-dmd
$ time ./test-dmd
init a[9555000] 0x0091EDF8           
init b[9555000] 0x00BBDFBD           
init b[9555000] 1449827528761239666688.000000

real    0m0.722s
user    0m0.552s
sys     0m0.168s

$ gdc  -O3 test-performance.d -o test-gdc && strip test-gdc
$ time ./test-gdc
init a[9555000] 0x0091EDF8
init b[9555000] 0x00BBDFBD
init b[9555000] 1449827528761239666688.000000

real    0m0.786s
user    0m0.628s
sys     0m0.152s

so, dmd's code optimization rules 
Walter made nice lang & good compiler - it's true

Jérôme M. Berger Wrote:

> alkor wrote:
> > maybe, i do something wrong, but for example:
> > 
> > $ cat main.d
> > int main () {
> >     return 0;
> > }
> > 
> > $dmd -O -release -ofmain-dmd main.d
> > $gdc -O3 main.d -o main-gdc
> > $ ls -l main-dmd main-gdc
> > -rwxr-xr-x 1 alkor alkor 123439 Dec 23 14:06 main-dmd
> > -rwxr-xr-x 1 alkor alkor 609363 Dec 23 14:06 main-gdc
> > 
> > why the main-gdc in 5 time more then the main-dmd?
> > 
> 	Because the dmd-built executable is stripped. Try to add "-s" to 
> the gdc command line or use gdmd with the same options as dmd.
> 
> 	Moreover, since you are trying to optimize for space rather than 
> performance, you should use -Os (or at least -O2) rather than -O3.
> 
> > any test shows dmd superiorities over gdc (and gcc)
> > dmd rules :)
> > 
> 	dmd doesn't even work on my computer. End of story :)
> 
> 		Jerome
> -- 
> mailto:jeberger at free.fr
> http://jeberger.free.fr
> Jabber: jeberger at jabber.fr
> 
> 




More information about the Digitalmars-d mailing list