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

Konstantin Tokarev annulen at yandex.ru
Fri Jan 22 11:56:32 CET 2016



22.01.2016, 13:32, "Bogdan Vatra" <bogdan.vatra at kdab.com>:
> 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.

Yeah, but compiler cannot perform some optimizations even when your code does not throw anything, just because exceptions are enabled, if it does not know for sure that called code may not throw.

>
> 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
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

-- 
Regards,
Konstantin



More information about the Development mailing list