Is this really that much impressive considering the fact that you compare results where the most work is done in the linked DLL itself no matter what code calls it, whether it is D or C, Debug or Release ??

On 14.07.2011 00:26, Andrej Mitrovic wrote:
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.

            • ... Walter Bright
  • ... Trass3r
  • ... М и х а и л С т р а ш у н
    • ... Trass3r
    • ... Walter Bright
      • ... Andrej Mitrovic
      • ... Extrawurst
        • ... Andrej Mitrovic
      • ... М и х а и л С т р а ш у н
        • ... Jonathan M Davis
  • ... Don
  • ... bearophile

Reply via email to