473,322 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 1313
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Jakob Bieling | last post by:
Hi, somehow the prejudice of exceptions being rather slow (compared to, ie. returning an error value and checking that) keeps sticking around .. at least around me. I guess this is also why I...
59
by: kk_oop | last post by:
Hi. I wanted to use exceptions to handle error conditions in my code. I think doing that is useful, as it helps to separate "go" paths from error paths. However, a coding guideline has been...
10
by: Timothy Graves | last post by:
I have a quick (pun intended) question for the guru's out there. I have a piece of code where I am validating the input of chancters into a cell in a datagrid. I am using the keypressed event to...
11
by: C# Learner | last post by:
What type of exception should I throw when my code detects that a connection has dropped (i.e. NetworkStream.Read() returns 0)? Should I just throw a SocketException or should I create my own...
6
by: RepStat | last post by:
I've read that it is best not to use exceptions willy-nilly for stupid purposes as they can be a major performance hit if they are thrown. But is it a performance hit to use a try..catch..finally...
9
by: Alvin Bruney [MVP] | last post by:
Exceptions must not be used to control program flow. I intend to show that this statement is flawed. In some instances, exceptions may be used to control program flow in ways that can lead to...
8
by: cat | last post by:
I had a long and heated discussion with other developers on my team on when it makes sense to throw an exception and when to use an alternate solution. The .NET documentation recommends that an...
40
by: Mark P | last post by:
I'm implementing an algorithm and the computational flow is a somewhat deep. That is, fcn A makes many calls to fcn B which makes many calls to fcn C, and so on. The return value of the outermost...
42
by: Jon Harrop | last post by:
Why are exceptions in C++ ~6x slower than exceptions in OCaml? -- Dr Jon D Harrop, Flying Frog Consultancy Objective CAML for Scientists...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.