日本精品aⅴ一区二区三区|国产欧美一二三区|国产乱码精品精|国产精品电影在线免费

      1. <blockquote id="utafg"><th id="utafg"></th></blockquote>
    1. <div id="utafg"></div>
        <blockquote id="utafg"><th id="utafg"></th></blockquote>

        <menuitem id="utafg"></menuitem>
      1. 您現在的位置是:首頁 >要聞 > 2023-12-01 04:36:19 來源:

        gettickcount函數(gettickcount)

        導讀 大家好,我是小夏,我來為大家解答以上問題。gettickcount函數,gettickcount很多人還不知道,現在讓我們一起來看看吧!1、原因是 LZ 對...

        大家好,我是小夏,我來為大家解答以上問題。gettickcount函數,gettickcount很多人還不知道,現在讓我們一起來看看吧!

        1、原因是 LZ 對機器太有愛心,測試個程序就給那么丁點“活兒”給它,太瞧不起它了~~

        2、這點工作, 現在的 CPU 水平不要幾個 ms 就能完成,只要 LZ 運行時機器不卡,下面的工作會在 16 個 ms 內完成,所以 begin 和 end 返回同樣的值

        3、for(int i =0; i<100; i++)

        4、 {

        5、 for(int j=0; j<100; j++)

        6、 {

        7、 a[i][j] = i+j;

        8、 }

        9、 }

        10、根據 MSDN 上面對于 GetTickCount 函數的描述:

        11、 “…… in the range of 10 milliseconds to 16 milliseconds ……”

        12、http://msdn.microsoft.com/en-us/library/ms724408%28VS.85%29.aspx

        13、改函數測試時間的精度是 10~16 ms,所以,如果你兩次調用 GetTickCount() 之間的工作如果在 16 ms 內完成,那么返回的時間差就有可能為 0

        14、LZ 只需要稍作修改,給 cpu 加點‘活’就能看出時間消耗了,比如下面

        15、以下代碼 VS2010 編譯通過,運行正常

        16、#include <windows.h>

        17、#include <iostream>

        18、using namespace std;

        19、int main()

        20、{

        21、 int a[200][200]; // 數組改大點,不要擔心你的寶貝機器會受不了,如果只是區(qū)區(qū)賦值而已,它眼都不眨一氣呵成。

        22、 DWORD begin,end,time;

        23、 begin = GetTickCount();

        24、 for(int i =0; i<200; i++)

        25、 {

        26、 for(int j=0; j<200; j++)

        27、 {

        28、 a[i][j] = i+j;

        29、 std::cout << a[i][j] << std:: endl; // 讓它一個一個輸出,這個可是比較可觀的“活兒”

        30、 }

        31、 }

        32、 end = GetTickCount();

        33、cout<<"begin="<<begin<<endl;

        34、 cout<<"end="<<end<<endl;

        35、 time = end - begin;

        36、 cout<<time;

        37、 return 0;

        38、}

        39、運行結果:

        40、…………… // 前面的省了

        41、 389

        42、 390

        43、 391

        44、 392

        45、 393

        46、 394

        47、 395

        48、 396

        49、 397

        50、 398

        51、 begin=12981375

        52、 end=12990625

        53、 9250請按任意鍵繼續(xù). . .

        54、我的老爺機,LZ 請無視結果

        本文到此講解完畢了,希望對大家有幫助。