public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Runtime overheads of C++ exceptions
@ 2003-09-09 15:34 Dhananjai M. Rao
  2003-09-09 16:25 ` Eljay Love-Jensen
  2003-09-10  3:36 ` Alex Vinokur
  0 siblings, 2 replies; 3+ messages in thread
From: Dhananjai M. Rao @ 2003-09-09 15:34 UTC (permalink / raw)
  To: gcc-help

Hello,

I am trying to figure out if C++ exceptions have any runtime performance
overheads.  In other words, let's say an exception is never thrown in my
c++ program, then would my c++ code run slower when compared with a
different version that does not use any exceptions (but does exactly the
same job).

thanks

with regards
-DJ


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Runtime overheads of C++ exceptions
  2003-09-09 15:34 Runtime overheads of C++ exceptions Dhananjai M. Rao
@ 2003-09-09 16:25 ` Eljay Love-Jensen
  2003-09-10  3:36 ` Alex Vinokur
  1 sibling, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2003-09-09 16:25 UTC (permalink / raw)
  To: Dhananjai M. Rao, gcc-help

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Runtime overheads of C++ exceptions
  2003-09-09 15:34 Runtime overheads of C++ exceptions Dhananjai M. Rao
  2003-09-09 16:25 ` Eljay Love-Jensen
@ 2003-09-10  3:36 ` Alex Vinokur
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Vinokur @ 2003-09-10  3:36 UTC (permalink / raw)
  To: gcc-help


"Dhananjai M. Rao" <dmadhava@ececs.uc.edu> wrote in message news:Pine.GSO.4.43.0309091132200.25498-100000@gatekeeper.ececs.uc.edu...
> Hello,
>
> I am trying to figure out if C++ exceptions have any runtime performance
> overheads.  In other words, let's say an exception is never thrown in my
> c++ program, then would my c++ code run slower when compared with a
> different version that does not use any exceptions (but does exactly the
> same job).
>
> thanks
>
> with regards
> -DJ
>
>

Look at
http://groups.google.com/groups?selm=bh5nja%24uqf37%241%40ID-79865.news.uni-berlin.de


   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-10  3:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-09 15:34 Runtime overheads of C++ exceptions Dhananjai M. Rao
2003-09-09 16:25 ` Eljay Love-Jensen
2003-09-10  3:36 ` Alex Vinokur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).