Port a benchmark to D?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Jun 3 16:05:24 PDT 2011


On 6/3/11 5:48 PM, bearophile wrote:
> Andrei:
>
>> Does anyone have the time and inclination to port the benchmark so we can take a look?
>
> My modified C++0x code:
> http://codepad.org/iBwINTkJ
>
> First D2 translation that seems to work:
> http://codepad.org/sEEFNlAd
>
> Notes on the translation:
> - The program crashes with zero error messages if you don't increase the stack. Time ago I have written an enhancement request on this:
> http://d.puremagic.com/issues/show_bug.cgi?id=6088

I think a better tail call optimization would be in order.

> - The final print of the "." done using write() doesn't perform the fflush. So after few tries I have used printf. I have not found a good way to flush. Suggestions welcome.

Just call stdout.flush().

> - The C++ code uses classes, but they are often more like D structs.
> In the first D version to keep things simple I have used final
> classes everywhere. I will profile the code and I will create a more
> efficient version that uses structs where needed.

Makes sense.

> - I have had to track down a null reference error (caused by the
> nodes array, that contains just references in the first D version).
> Nonnullable type modifiers avoids similar bugs at compile-time.

Stay tuned. Good news coming soon.

[snip]

This is solid work. Looking forward to seeing measurements!


Thanks,

Andrei


More information about the Digitalmars-d mailing list