Using QueryPerformanceCounter in c sharp but not getting precise results
I am using QueryPerformanceCounter to get the precise timing behaviour in my c sharp program. But if i measure the timing using thread.sleep it is not giving excpected results. I followed standard example given at m开发者_运维百科sdn site: http://msdn.microsoft.com/en-us/library/ff650674.aspx
myTimer.Start();
for (int i = 0; i < iterations; i++)
{
// Method to time
System.Threading.Thread.Sleep(1000);
}
myTimer.Stop();
Results are :
Iterations: 5 Average time per iteration: 0.208957983452184 seconds
Datetime.Now gives :
Duration of test run: 5 seconds 5000 milliseconds
Can you please suggest what could be possible error?
精彩评论