using System; using System.Diagnostics; using System.Threading; class Program { static void Main() { decimal totalElapsedTicks = 0; // Create new stopwatch Stopwatch stopwatch = new Stopwatch(); // Do something for (int i = 0; i < 100000; i++) { try { // Begin timing stopwatch.Start(); RethrowException(); }catch { // Stop timing stopwatch.Stop(); } } // Write result Console.WriteLine("try/catch technique: {0:#,###,###,###}", stopwatch.ElapsedTicks); stopwatch.Reset(); // Do something for (int i = 0; i < 100000; i++) { try { // Begin timing stopwatch.Start(); PassThroughException(); }catch { // Stop timing stopwatch.Stop(); } } // Write result Console.WriteLine("try/finaly technique: {0:#,###,###,###}", stopwatch.ElapsedTicks); } static void RethrowException() { try { throw new Exception(); } catch { DummyMethod(); throw; } } static void PassThroughException() { bool exceptionThrown = false; try { exceptionThrown = true; throw new Exception(); } finally { if(exceptionThrown) { DummyMethod(); } } } static int DummyMethod() { return 0; } }