Re: Runtime overheads of C++ exceptions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi DJ,

Run your tests via...
g++ -fno-exceptions test.cpp -o test_without_exception_overhead
g++ test.cpp -o test_with_exceptions
...and compare the runtime performance overhead that is pertinent to your project.

Note that exception handling provides a mechanism that reduces program complexity and avoids often neglected unfilled contract situations that often go undetected because the return code indicating failure is ignored.  To be fair, you should factor in both of those issues into your analysis.

Generally speaking with most modern C++ compilers, there is NO runtime overhead for the exception framework in terms of CPU cycles wasted -- UNLESS an exception occurs.  Exceptions are "expensive" and should NEVER be used for mere flow control. 

There is some overhead in terms of memory footprint -- exception frames on the stack and such, used for unwinding, and the exception tables that take up some memory.  I presume those kinds of overhead costs are not much of a concern.

HTH,
--Eljay



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux