I searched this question but didn't see an answer. If it is a duplicate I'll gladly close it.
I am currently trying to do some performance evaluation on a technology and saw some rather unbelievable results so I decided to experiment some. In that I wanted to try and see if the Stopwatch class was returning what I expected.
Stopwatch sw = Stopwatch.StartNew();
Thread.Sleep(1);
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
In this case I was pretty much seeing a return value of 15ms. I understand the resolution of DateTime to be around there but shouldn't Thread.Sleep(1) sleep a thread for 1ms? The system I am on returns Stopwatch.IsHighResolution true and its running in .NET 4.
Background: This code in its complete and proper form is intended to gather some numbers on Aerospike db get requests. The DB is not on the same box. When I printed out the sw.ElapsedMilliseconds when a query was in the middle I'm seeing mostly sub millisecond responses and that sounds a little suspect considering my Java equivalent code is returning much more believable 5ms-15ms responses most of the time. The Java code is using the difference of System.nanoTime(). By submilli responses in my C# code I mean Console.WriteLine(sw.ElapsedMilliseconds) prints 0.