Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Measuring exception handling overhead in C++

What is the best way to measure exception handling overhead/performance in C++?

Please give standalone code samples.

I'm targeting Microsoft Visual C++ 2008 and gcc.

I need to get results from the following cases:

  1. Overhead when there are no try/catch blocks
  2. Overhead when there are try/catch blocks but exceptions are not thrown
  3. Overhead when exceptions are thrown
like image 313
Antti Kissaniemi Avatar asked Sep 04 '08 06:09

Antti Kissaniemi


2 Answers

As a suggestion: don't bother too much with the overhead when exceptions are thrown. Exception handling implementations usually make not throwing fast and catching slow. That's ok since those cases are, well, exceptional.

Carl

like image 20
Carl Seleborg Avatar answered Oct 19 '22 23:10

Carl Seleborg


Section 5.4 of the draft Technical Report on C++ Performance is entirely devoted to the overhead of exceptions.

like image 154
Xavier Nodet Avatar answered Oct 19 '22 23:10

Xavier Nodet