• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            天下

            記錄修行的印記

            GetTickCount()函數(shù)

             

            在要求誤差不大于1毫秒的情況下,可以采用GetTickCount()函數(shù),該函數(shù)的返回值是DWORD型,表示以毫秒為單位的計(jì)算機(jī)啟動(dòng)后經(jīng)歷的時(shí)間間隔。使用下面的編程語(yǔ)句,可以實(shí)現(xiàn)50毫秒的精確定時(shí),其誤差小于1毫秒。

            對(duì)于一般的實(shí)時(shí)控制,使用GetTickCount()函數(shù)就可以滿足精度要求,但要進(jìn)一步提高計(jì)時(shí)精度,就要采用QueryPerformanceFrequency()函數(shù)和QueryPerformanceCounter()函數(shù)。
            這兩個(gè)函數(shù)是VC提供的僅供Windows使用的高精度時(shí)間函數(shù),并要求計(jì)算機(jī)從硬件上支持高精度計(jì)時(shí)器。QueryPerformanceFrequency()函數(shù)和QueryPerformanceCounter()函數(shù)的原型為:

            The QueryPerformanceFrequency function retrieves the frequency of the high-resolution performance counter, if one exists. The frequency cannot change while the system is running.

            BOOL QueryPerformanceFrequency(         
                LARGE_INTEGER *lpFrequency
            );

            Parameters

            lpFrequency
            [out] Pointer to a variable that receives the current performance-counter frequency, in counts per second. If the installed hardware does not support a high-resolution performance counter, this parameter can be zero.
            Return Value

            If the installed hardware supports a high-resolution performance counter, the return value is nonzero.

            If the function fails, the return value is zero. To get extended error information, call GetLastError. For example, if the installed hardware does not support a high-resolution performance counter, the function fails.


            The QueryPerformanceCounter function retrieves the current value of the high-resolution performance counter.
            BOOL QueryPerformanceCounter(         
                LARGE_INTEGER *lpPerformanceCount
            );
            Parameters

            lpPerformanceCount
            [out] Pointer to a variable that receives the current performance-counter value, in counts.
            Return Value

            If the function succeeds, the return value is nonzero.

            If the function fails, the return value is zero. To get extended error information, call GetLastError.



            Linux下的:

             

            #include <sys/time.h>
            unsigned 
            long GetTickCount()
            {
                
            struct timeval tv;
                
            if (gettimeofday(&tv,NULL) !=0) {
                    
            return 0;    
                }
                
            return (tv.tv_sec*1000)+(tv.tv_usec/1000);
            }

            posted on 2011-03-05 09:50 天下 閱讀(4118) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Win32

            <2012年2月>
            2930311234
            567891011
            12131415161718
            19202122232425
            26272829123
            45678910

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿(4)

            隨筆分類(378)

            隨筆檔案(329)

            鏈接

            最新隨筆

            搜索

            最新評(píng)論

            精品久久久久久久久免费影院| 久久美女网站免费| 国产精品丝袜久久久久久不卡 | 中文国产成人精品久久不卡| 久久国产精品一区| 国产成人综合久久精品尤物| 丰满少妇高潮惨叫久久久| 欧美噜噜久久久XXX| 无码人妻久久久一区二区三区| 一本色道久久88—综合亚洲精品| 亚洲国产日韩综合久久精品| 韩国免费A级毛片久久| 久久精品国产亚洲AV麻豆网站 | 色诱久久av| 中文字幕久久亚洲一区| 久久精品国产99久久久| 99久久久精品| 97超级碰碰碰碰久久久久| 99久久综合国产精品二区| 久久久综合香蕉尹人综合网| 久久91精品国产91| 久久av无码专区亚洲av桃花岛| 久久九九有精品国产23百花影院| 蜜桃麻豆www久久| 亚洲精品综合久久| 99久久婷婷免费国产综合精品| 国内精品久久久久久久涩爱 | 九九久久精品国产| 久久人人添人人爽添人人片牛牛| 少妇高潮惨叫久久久久久 | 国产激情久久久久影院| 午夜精品久久久久| 狠狠色婷婷综合天天久久丁香| 精品久久人人妻人人做精品 | 久久久久无码国产精品不卡| 精品国产乱码久久久久软件| 国产91色综合久久免费| 亚洲国产视频久久| 品成人欧美大片久久国产欧美... 品成人欧美大片久久国产欧美 | 久久96国产精品久久久| 久久久亚洲AV波多野结衣|