what is stopWatch: Stopwatch is a class in C# to measure the elapsed time. Use it to calculate the time a function took to execute. It is found under System.Diagnostics.
How stopWatch work: To get the elapsed time, firstly begin the Stopwatch −
var sw = Stopwatch.StartNew();
For elapsed ticks
long ticks = sw.ElapsedTicks;
example
using System; using System.Linq; using System.Diagnostics; public class Demo { public static void Main() { var sw = Stopwatch.StartNew(); long ticks = sw.ElapsedTicks; Console.WriteLine(ticks); } }