Your results seem strange

AKhropov andkhropov at nospam_mtu-net.ru
Fri Jun 9 10:04:25 PDT 2006


pragma wrote:

> In article <e6c2kn$m48$1 at digitaldaemon.com>, James Pelcis says...
> > My results (averaged and rounded) were 5,575,010,530 for C++ and 
> > 8,339,840,041 for D.  Since it was with the same linker, optimizer, 
> > etc., this is a bad sign.  Is the problem in the code or the compiler?
> 
> I can confirm. Using your source code, comparing DMC to DMD, I got:
> 
> C:\home\pragma\src\test>ackcpp.exe
> 7982698959 clock cycles elapsed.
> 
> C:\home\pragma\src\test>ackd.exe
> 10881160506 clock cycles elapsed.
> 
> Now on a whim, I added "extern(C)" to the definition of Ack() like so:
> 
> > extern(C) int Ack(int a, int b){ /* ... */ }
> 
> And got this:
> 
> C:\home\pragma\src\test>ackcpp.exe
> 7371540535 clock cycles elapsed.
> 
> C:\home\pragma\src\test>ackd.exe
> 7057883217 clock cycles elapsed.

Did your turn maximum optimization on?

Here are my results with James' code:

--- compiler flags: -----
dmc akk2.cpp -o -oakk2-cpp.exe
dmd akk2.d -O -release -inline -ofakk2-d.exe
-------------------------

1) both variants without "extern (C)"
 
C++: 4379147218 clock cycles elapsed.
D  : 3669672891 clock cycles elapsed.

2) both variants with "extern (C)" (well, "extern "C"" in C++ case)

C++: 4414772278 clock cycles elapsed.
D  : 4394787775 clock cycles elapsed.

So, turning on "extern (C)" actually made it slower and approximately the same
speed as C++.


So, I think the problem is in the back-end (which is the same for DMD and DMC
AFAIK ).

It would be interesting to hear from guys using GDC with GCC back-end.

-- 
AKhropov



More information about the Digitalmars-d mailing list