Here is a sample bit of code to time an operation:
Dim sw As New Stopwatch()
sw.Start()
//Insert Code To Time
sw.Stop()
Dim ms As Long = sw.ElapsedMilliseconds
Console.WriteLine("Total Seconds Elapsed: " & ms / 1000)
EDIT:
And the neat thing is that it can resume as well.
Stopwatch sw = new Stopwatch();
foreach(MyStuff stuff in _listOfMyStuff)
{
sw.Start();
stuff.DoCoolCalculation();
sw.Stop();
}
Console.WriteLine("Total calculation time: {0}", sw.Elapsed);
The System.Diagnostics.Stopwatch class will use a high-resolution counter if one is available on your system.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…