using System; using System.Diagnostics; public class Test { public static void Main() { // Create new stopwatch Stopwatch stopwatch = new Stopwatch(); // Begin timing stopwatch.Start(); System.Threading.Thread.Sleep(500); // Stop timing stopwatch.Stop(); Console.WriteLine("Time elapsed: {0}", stopwatch.Elapsed); } }