dmd 1.069 and 2.054 release

Andrej Mitrovic andrej.mitrovich at gmail.com
Wed Jul 13 15:26:42 PDT 2011


Damn, I am getting some impressive results comparing VC C++ builds and
DMD D builds. I'm using the PortAudio library and a stress-test that
comes with the project. It tries to generate as many sinewaves as
possible until some maximum is reached. The PortAudio C DLL library is
built in release mode, and is then implicitly linked with a C or D
project. Here's the results:

Stops on 500 max sines, or 0.80 max cpu.

C debug:
numSines = 229, CPU load = 0.802464  // cpu max reached

C release:
numSines = 500, CPU load = 0.793717  // max sines reached

D debug:
numSines = 258, CPU load = 0.800412  // cpu max reached

D release:
numSines = 500, CPU load = 0.629622  // max sines reached


Notice how the C version barely made it to 500 sines in release mode
(almost hit 0.80 CPU), but the D version had plenty of free CPU left
(this is all done on a single core).

I've enabled debug symbols and explicitly enabled floating-point
exceptions in debug builds in the realtime-priority callback function,
via:
    version (Debug)
    {
        import std.math;
        FloatingPointControl fpc;
        fpc.enableExceptions(FloatingPointControl.severeExceptions);
    }

and that still beats C's debug build by a small margin. There were 3
function macros which I've converted to auto templates, I think those
got inlined in release mode. I'm using exceptions in the D version
compared to C's use of goto's.

Here's the C version code: http://codepad.org/4ERFVcSS
And the D version: http://codepad.org/a7XL8wNW

D debug switches (I had to use Debug instead of debug due to a
critical bug): -g -version=Debug
D release switches: -release -inline -O -noboundscheck

Anyway if you want to try it yourself (Windows only for now), do:
git clone https://github.com/AndrejMitrovic/DPortAudio

cd and run \portaudio\build.bat
cd and run \samples\build.bat

The C examples are in the PortAudio project and if you want to compare
with those you'll have to build them yourself.


More information about the Digitalmars-d-announce mailing list