C# .Net using the StopWatch() class to measure execution performance

The StopWatch class is a member of the System.Diagnostics namespace, it’s a really useful way to get some information on how long a block of code is taking to execute. To setup a timing session, this is how you do it.

using System.Diagnostics;
var stopwatch = Stopwatch.StartNew();

// Where FFFFFFF represents milliseconds format
Console.WriteLine("Time: {0:FFFFFFF}", stopwatch.Elapsed);

Leave a Reply

Your email address will not be published. Required fields are marked *