Code Execution Timing in .Net

The Stopwatch class  is a quick and easy way to get executing timings from your code.

The example code below shows how to get the execution time from a section of code:

     using System.Diagnostics;

     Stopwatch timer = new Stopwatch();
     timer.Start();
     // Enter the code here that you want to time
     timer.Stop();
     long elapsedTime = timer.ElapsedMilliseconds;