Measure time in C# .NET (edit)
Two ways to measure time in C# .NET | Exercises in .NET with Andras Nemes (dotnetcodr.com)
Two ways to measure time in C# .NET
static void Main(string[] args)
{
DateTime start = DateTime.UtcNow;
Thread.Sleep(2000);
DateTime end = DateTime.UtcNow;
TimeSpan timeDiff = end - start;
Console.WriteLine(Convert.ToInt32(timeDiff.TotalMilliseconds)); // => 2005
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
Thread.Sleep(2000);
stopwatch.Stop();
stopwatch.Start();
Thread.Sleep(3000);
stopwatch.Stop();
TimeSpan stopwatchElapsed = stopwatch.Elapsed;
Console.WriteLine(Convert.ToInt32(stopwatchElapsed.TotalMilliseconds)); // => 5014
}
Favorite Links
Stack Overflow - Where Developers Learn, Share, & Build Careers
C# Corner - Community of Software and Data Developers (c-sharpcorner.com)
CodeProject - For those who code