Woeful performance of D compared to C++
Bill Lear
rael at pppp.zopyra.com
Thu Jan 18 13:10:00 PST 2007
Pragma <ericanderton at yahoo.removeme.com> writes:
> rael at seesig.com wrote:
> > In other benchmarks I've seen, D seems quite competitive with C/C++.
> > I seem to have written a very simple program that shows D in a very
> > poor light compared to C++. I wonder if it is my inexperience.
> [snip]
> > Any help would be appreciated.
>
> I'm gobsmacked. No array concatenation, strings, large allocations,
> or even floating point. Just integer math and comparisons.
>
> Check the obvious stuff first: disable the GC, compile with "-inline
> -release" for GDC to match the "-O3 -o" that you're using on GCC.
Hmm, tried -release and -O -inline, but not disable GC. I'll
throw a spare whirl that way and see how that goes.
> The only part of that loop that is of any consequence is the call to
> rand() - odds are they are two completely different algorithms, with
> D's being slower (performance test anyone?). Everything else should
> reduce to almost the same exact machine code.
The rand() call is definitely the most expensive. When I remove it
from both the C++ and the D program, the times plummet (to 0.003
and 0.013 seconds, respectively --- still, however, leaving the D
program running in 4.3 times that of the C++ program;-).
Bill
--
Bill Lear
r * e * @ * o * y * a * c * m
* a * l * z * p * r * . * o *
More information about the Digitalmars-d
mailing list