Hi there,
Sorry if the question is a bit vague. I have some code surrounded by a try catch. The piece of code can potentially take hours to compute.
I'm wondering is there a performance hit is using a try catch? If there is are we talking a 10% hit? More?
Loading

AlanRank #669 · 3.6K reputationPosted Sep 16, 2008, 7:29 AM EDT
There is a performance hit in using try/catch/finally but how big it is will depend on:
1. What you're doing within the try statement.
2. The additional cost of doing something else (such as testing a method return value) if there's an error.
In view of this it's very difficult to put a figure on it but, if you think in terms of a 10 to 20% hit on average, then I don't think you'll be far away.
Kevin15 reputationPosted Sep 16, 2008, 7:39 AM EDT
try
{
object a = Method();
}
catch(System.Exception m)
{
MessageBox.Show(m.Message);
}
finally
{
//Cuts a thread elsewhere
}
AlanRank #669 · 3.6K reputationPosted Sep 16, 2008, 8:27 AM EDT
Ryan AlfordRank #1,411 · 1.2K reputationPosted Sep 16, 2008, 11:43 AM EDT
Kevin15 reputationPosted Sep 17, 2008, 4:32 AM EDT