On my computer the Stopwatch is returning values way too low. For example, 200 ms when I specified Thread.Sleep(1000)
. The program is supposed to wait 1 second. I a
I got this:
1000 ms for DateTime.Now.Ticks
0999 ms for Stopwatch.ElapsedTicks
1000 ms for Stopwatch.ElapsedMilliseconds
0999 ms for Stopwatch.ElapsedTicks after Reset
0999 ms for Stopwatch.ElapsedTicks setting ThreadAffinity
0999 ms for Stopwatch.ElapsedTicks setting ProcessorAffinity (and more)
(Couldn't run the last test)
On a quad-core i7 machine with .NET4 in Linqpad.
I only ever tend to use Stopwatch.ElapsedMilliseconds but I've never seen anything odd about it. It does sound like there's something broken about your machine or virtualization platform.