Re: perf & Try Catch

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 01/01/05


Date: Sat, 1 Jan 2005 11:29:14 -0000

David Levine <noSpamdlevineNNTP2@wi.rr.com> wrote:

<snip>

> What I think happens is that when a try block is entered some CLR
> housekeeping microcode (for want of a better term) is executed, and the same
> when a catch and a finally block are entered - this may be where the
> additional execution time comes from.

Having had a look at the JITted code, I think it's more a case of the
JIT not being able to optimise as heavily, not being able to enregister
as much.

Personally I think that apart from a very, *very* few situations,
exception handling should be implemented according to elegant design
rather than optimal performance. In the case we're talking about, the
processing within the loop would have to be *very* simple for the cost
of adding the try/catch to end up being particularly significant.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages