|
-
May 15th, 2008, 05:08 PM
#1
Try....Catch and Performance
Do try...catch block affects the performance of the application... even tough if exception is never thrown??If yes is it soo significance ?
-
May 15th, 2008, 06:13 PM
#2
Re: Try....Catch and Performance
I don't believe Try or Finally reduce performance at all (or if they do, it's so tiny that it wouldn't be noticeable). Catch is a little different. Throwing an exception is expensive so when Catch is called, performance is hurt.
-
May 15th, 2008, 07:00 PM
#3
Re: Try....Catch and Performance
Every time a function or sub is invoked there is a passing of control from one program-counter location to another.
The runtime engine is handling this.
It's got unavoidable error detection running at all times - so that when an error is thrown and you don't have logic in the error handler the error value can be passed back up to the calling function.
All this is in place regardless.
Having an error handler means that you are placing code in a location to be "run through" in the event an error is detected.
Everytime you choose one syntax construct over another you are introducing additional steps in code that the program counter must move through (or reducing those steps).
Considering where app performance is hindered is a good thing - but this is certainly not one of them.
-
May 16th, 2008, 06:20 AM
#4
Re: Try....Catch and Performance
One thing that most definately DOES affect an application is NOT having error traps. Regardless of the consequences, some form of error trapping should always be a part of all code.
-
May 16th, 2008, 09:11 AM
#5
Re: Try....Catch and Performance
What platform? What language?
-
May 16th, 2008, 09:55 AM
#6
Re: Try....Catch and Performance
.NET platform and any .NET language
-
May 16th, 2008, 10:55 AM
#7
Re: Try....Catch and Performance
Regardless, it is better to have it, than not have it.
-
May 16th, 2008, 01:46 PM
#8
Re: Try....Catch and Performance
According to what I read in MSDN, there is no cost for error handling as long as there are no exceptions raised.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|