Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Is "Try Catch" slow?Is "Try Catch" slow?
Previous
 
Next
New Post
6/20/2008 5:34 AM
 

Dear Colleagues!

Did anyone measure speed with using of "Try Catch"? Is it slow? if yes, then how much slow? 10%,50%, 100% more?

Reason of question: we develop httpModule and adding "Try Catch" makes process of load more slowly.

Thanks in advance!

Sergey

 
New Post
6/20/2008 7:12 PM
 

try catch is actually very fast, as it's catching the exception locally, and the only real effort is serialising the error message. See http://www.codeproject.com/KB/exception/ExceptionPerformance.aspx for some real statistics. I'm not sure why try catch is making your app run slowly, are you using a finally block or implmenting IDisposable, perhaps some clean up code in either of those areas is causing your performance issues.

Cathal


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
6/20/2008 8:12 PM
 

Cathal

Thank you for your comment and link. We have added special code allows to measure time for each line and here is some results:

1) Simple "Try Catch" does not make code slowly. Exactly the same as without.

2) 2 blocks of "Try Catch" one inside other make code slowly for 8-10% :(

We sure that #2 is not good style of development. We will try to make code fully without of "Try Catch" and will replace them with correct conditions.

Again thank you for your comment. We will post additional info as soon will have it.

Sergey

 
New Post
6/20/2008 9:05 PM
 

I do recall some debate back in 2005 on this very topic, and there being some general disagreement in the community about the speed acceptability.  One bookmark that still works is at http://www.codinghorror.com/blog/archives/000358.html, which provides some additional data on the topic.  I suspect that this area has had some subsequent serious development, and throw performance nowadays is quite fine (at least IMO).

One point not yet raised, however, is that exception performance is generally pretty horrible under a debug build and in an IDE environment (at least it was in vs2005). 

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post
6/21/2008 7:28 AM
 

Brandon

Thank you very much for this so interesting information. We will research it. Also we are in researhc mode and it looks like question is really interesting and complex. In generally one idea: better do not use Try Catch at all, but build correct code (hmm not sure it is possible, but will try) OR to use ONLY ONE Try Catch at PageLoad. We will post additional information.

Sergey

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Is "Try Catch" slow?Is "Try Catch" slow?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out