Some sub's in my VB.Net program take a lot of time, and I do not understand why. I'd like to start a counter at the beginning of the sub and write the Milliseconds passed for each row in the console.
I tried using a Timer and resetting it after each row but it was too threadintesive. Is there a better way, using the system date/time in order to get a quite precise reading of the time each step takes?
Thank you
Use the Stopwatch
class. However doing so for each row seems a bit impossible... That means you would have to add for example Console.WriteLine()
after every row.
Example usage:
Dim sw As New Stopwatch
sw.Start()
yourMethod()
sw.Stop()
Console.WriteLine(String.Format("{0} ms", sw.Elapsed.TotalMilliseconds))