Re: [linux-audio-dev] soft synth as a plugin

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] soft synth as a plugin
From: Tim Goetze (tim_AT_quitte.de)
Date: Sat Oct 19 2002 - 01:42:49 EEST


Stefan Nitschke wrote:

>>
>>erm, sorry, but why not use pointers?
>>
>
>Just out of couriosity i made a benchmark test between C and C++ with
>gcc3. I dont have a clue abour x86 assembler so i made a measurement.
>
>Here is the C code (not realy useful as real code would have a need for a
>struct and a pointer operation to call the filter() function) and the
>C++ code.
>Both "simulate" a low pass filter and are compiled with:
> gcc -O2 -march=pentium -o filter filter.xx
[...]
>C++ with member:
>real 0m11.847s
>user 0m11.850s
>sys 0m0.000s
>
>C++ with new() and pointer:
>real 0m12.337s
>user 0m12.330s
>sys 0m0.000s
>
>C:
>real 0m16.673s
>user 0m16.670s
>sys 0m0.000s

my interpretations:

c++ sans new() might be quicker because of better cache
locality (the class instance is just a local stack var,
while with new() it is somewhere on the heap in another
memory page).

i don't think reference and pointer access make the
difference, after all the internal representation should
be the same. granted, new() is a lot slower than a local
class on the stack but your code only allocates once.

have you checked whether the optimizer inlined the C
function call? it looks like it didn't.

tim


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Sat Oct 19 2002 - 01:53:47 EEST