DateTime begin = DateTime.UtcNow; ... DateTime end = DateTime.UtcNow; Console.WriteLine("Execution time: " + (end-begin).TotalMilliseconds + " ms.");
Stopwatch watch = new Stopwatch(); watch.Start(); ... watch.Stop(); Console.WriteLine("Execution time: " + watch.Elapsed.TotalMilliseconds + " ms.");
TimeSpan begin = Process.GetCurrentProcess().TotalProcessorTime; ... TimeSpan end = Process.GetCurrentProcess().TotalProcessorTime; Console.WriteLine("Execution time: " + (end - begin).TotalMilliseconds + " ms.");