Port a benchmark to D?

Adam D. Ruppe destructionator at gmail.com
Fri Jun 3 16:09:18 PDT 2011


bearophile wrote:
> My modified C++0x code:
> First D2 translation that seems to work:

What timings did you get? On my computer, the D version ran
slightly faster (56 seconds vs 63s for C++) without optimizations
turned on.

With optimizations turned on, C++ took a nice lead (28 seconds vs 53
seconds for D).


This is similar to other benchmarks I've run in the past. Standard
D builds beat standard C++ builds, but gcc's optimizer takes the
lead vs dmd's optimizer.

However, in the past, I've found writing D style instead of C++
style lets standard D beat even optimized g++. I wonder if that's
the case here too..

> - 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.


To flush with D's stdout, simply call stdout.flush:

write(".");
stdout.flush();


More information about the Digitalmars-d mailing list