开发者

Using QueryPerformanceCounter in c sharp but not getting precise results

开发者 https://www.devze.com 2023-02-04 16:40 出处:网络
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 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消