Overhead in C and C++
Steven Bosscher
stevenb.gcc@gmail.com
Thu Feb 25 14:43:00 GMT 2010
On Thu, Feb 25, 2010 at 3:35 PM, <cmauchle@hsr.ch> wrote:
> Hellow gcc,
>
> i'm working on the topic "overhead and codesize in C and C++". The goal of this work is to find out, why C++ is not as fast as normal C code (in same application).
>
> But already by the beginning we found out something very interesting.
>
> The Code:
> int main(int argc, char *argv[])
> {
> return 0;
> }
> No function so far. But this compiled with gcc and g++ (on Linux Redhead EL5, Intel Xeon 5130 (x86_64))
>
> Codesize in C: 7820
> Codesize in C++: 8175
>
> But much more interesting is the number of instructions (mesured with callgrind/kcachegrind):
> For main:
> Ir in C: 7
> Ir in C++: 7
> Whole program (you see, there is no include)
> Ir in C: 80 158 (a lot)
> Ir in C++: 1 295 980 (massive!!)
>
> C++ has a mulitple of C-Instructions. Why is that such enorm?
>
> Is there any idea or better documenation about this topic? Thank you for your answer
The least you should do before anyone can answer this, is tell us what
compiler options you used.
Ciao!
Steven
More information about the Gcc
mailing list