470,590 Members | 2,404 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,590 developers. It's quick & easy.

Exceptions + Performance on path without exceptions

The application I'm working on will run on Linux, in user space. If I
use exception handling in parts of the application, will that affect
the performance of sections of code which do not use any exception
handling? Basically, I'm looking at optimizing a critical path, and
wondering if I can keep the exceptions elsewhere in code which are
working fine.

Apr 16 '07 #1
3 1218
On 16 Apr., 19:23, gratc...@gmail.com wrote:
The application I'm working on will run on Linux, in user space. If I
use exception handling in parts of the application, will that affect
the performance of sections of code which do not use any exception
handling? Basically, I'm looking at optimizing a critical path, and
wondering if I can keep the exceptions elsewhere in code which are
working fine.
One common implementation of exception handling adds overhead only in
the case that an exception is thrown, and so far as I know gcc on
Linux uses that approach. In that case you should be safe in all the
unexceptional cases, but you'd need to measure before knowing for
sure, of course.

/Peter

Apr 16 '07 #2
On 2007-04-16 19:23, gr******@gmail.com wrote:
The application I'm working on will run on Linux, in user space. If I
use exception handling in parts of the application, will that affect
the performance of sections of code which do not use any exception
handling? Basically, I'm looking at optimizing a critical path, and
wondering if I can keep the exceptions elsewhere in code which are
working fine.
First of all, do you have any reason (such as measurements) to believe
that your code is losing execution-speed due to exceptions? Don't forget
the golden rule of optimization: measure first.

Some compilers allow you to turn off exceptions, so if you can compile
the critical code without exceptions and the other with it might solve
the problem for you. But it probably means creating special rules in
your Makefiles or whatever you are using.

--
Erik Wikström
Apr 16 '07 #3
gr******@gmail.com writes:
The application I'm working on will run on Linux, in user space. If I
use exception handling in parts of the application, will that affect
the performance of sections of code which do not use any exception
handling? Basically, I'm looking at optimizing a critical path, and
wondering if I can keep the exceptions elsewhere in code which are
working fine.
You must have used a profiler to identify the critical path, right? What
did the profiler say about the code you're asking about?

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
Apr 16 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Jakob Bieling | last post: by
59 posts views Thread by kk_oop | last post: by
10 posts views Thread by Timothy Graves | last post: by
11 posts views Thread by C# Learner | last post: by
6 posts views Thread by RepStat | last post: by
9 posts views Thread by Alvin Bruney [MVP] | last post: by
40 posts views Thread by Mark P | last post: by
42 posts views Thread by Jon Harrop | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.