[Development] What kind of airplane we want to build?

Bogdan Vatra bogdan.vatra at kdab.com
Fri Jan 22 11:32:25 CET 2016


On Friday 22 January 2016 10:55:34 Cristian Adam wrote:
> On Fri, Jan 22, 2016 at 11:59 AM, Marc Mutz <marc.mutz at kdab.com> wrote:
> > I'm not sure about what outcome to expect, and I don't remember any
> > numbers
> > posted by anyone else, either.
> 
> From the David Stone's Writing Robust Code
> <https://meetingcpp.com/tl_files/2014/talks/robust_code.pdf> page 34:
> 
> Performance of exceptions when not thrown
> ● Tested on gcc 4.9.2
> ● Numbers relative to ignoring errors
> ● With no destructors
>     – 12.8% overhead for exceptions
>     – 32.8% overhead for return codes
> ● With destructors
>     – 6.3% overhead for exceptions
>     – 18.7% overhead for return codes
> 

Hmm, so, using exceptions makes your code 12-20% faster. This is a good thing, 
right?. Most probably the binary size will be slightly bigger, let's see if 
it's 12-20% bigger (my hunch is that it will not be more than 5% bigger). I'll 
do some tests this weekend and I'll share with you the results.

> And page 35:
> 
> Performance of exceptions when thrown
> ● Tested on gcc 4.9.2
> ● Numbers relative to ignoring errors
> ● With no destructors
>     – 900% overhead for exceptions
> ● With destructors
>     – 750% overhead
> 

As I said, exceptions are like *a life vest*, they should be used *only in 
critical situations* not everywhere.

Cheers,
BogDan.

P.S. Android Alexandrescu has a nice video on this matter:
https://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C




More information about the Development mailing list