I am trying to run a test on some code. I use a stopwatch. When I output the number of milliseconds, it always tells me 0, so I thought that I would try the number of ticks. I can see that the number of ticks is between 20,000 and 30,000. Looking at the MSDN in TimeSpan.TicksPerMillisecond, he says it's 10,000 ticks per millisecond. In this case, why the past milliseconds on my stopwatch are not displayed as 2 or 3?
What am I missing? I even returned the result on the same line. This is what I get.
Time taken: 26856 ticks, 0 ms
And he is permanent.
EDIT (code added) This is my code that I run in a loop. I understand that every time I create a new stopwatch, which is not very effective, but I do not see how this can distort my results. Thanks guys
Dim SW = New Stopwatch() SW.Reset() SW.Start() MethodCall() SW.Stop() Console.WriteLine(String.Format("Time to increase counters: {0} ticks, {1} ms", SW.ElapsedTicks, SW.ElapsedMilliseconds))
uriDium
source share