Why does ElapsedTicks X 10 000 not equal ElapsedMilliseconds for .Net's Stopwatch?

Posted by uriDium on Stack Overflow See other posts from Stack Overflow or by uriDium
Published on 2010-06-09T15:49:37Z Indexed on 2010/06/09 15:52 UTC
Read the original article Hit count: 199

Filed under:
|

I am trying to performance test some code. I am using 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 am seeing that the number of ticks is about 20 000 to 30 000. Looking at the MSDN at TimeSpan.TicksPerMillisecond it says that is 10 000 ticks per millisecond. In that case why are the elapsed milliseconds on my stopwatch not appearing as 2 or 3?

What am I missing? I have even outputed the result on the same line. This is what I get.

Time taken: 26856 ticks, 0 ms

And it is constant.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about Performance