• <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>

            MyMSDN

            MyMSDN記錄開發新知道

            計時器代碼片段

            這不是一個面向對象的代碼庫,它的存在僅僅只是為了說明幾個函數調用,如果要在您的工程中應用相關內容,請自行構建(這應該不難),或者看看我推薦的文檔。

            // ProcessAffinity.cpp : 定義控制臺應用程序的入口點。
            //
            
            #include "stdafx.h"
            #include <windows.h>
            #include <iostream>
            #include <vector>
            
            using namespace std;
            void DisplayFrequency(ostream &out, LARGE_INTEGER &freq);
            
            struct TimeSpan
            {
                LARGE_INTEGER *Frequency;
                LARGE_INTEGER StartCounter;
                LARGE_INTEGER StopCounter;
                BOOL HAS_ERROR;
                double CalTimeSpan(){
                    return (StopCounter.QuadPart - StartCounter.QuadPart)/Frequency->QuadPart;
                }
            };
            
            int _tmain(int argc, _TCHAR* argv[])
            {
                HANDLE CurrentProcessHandle;
                DWORD ProcessAffinityMask, SystemAffinityMask, AllowProcessAffinity;
            
                CurrentProcessHandle = GetCurrentProcess();
            
                //GetCurrentProcess返回一個常量,代表當前的進程句柄
                cout<<CurrentProcessHandle<<endl;
                cout<<(HANDLE)-1<<endl;
                cout<<(void*)-1<<endl;
                cout<<(void*)0xffffffff<<endl;
            
                cout<<"-----------------------------"<<endl;
            
                if(GetProcessAffinityMask(CurrentProcessHandle, &ProcessAffinityMask, &SystemAffinityMask))
                {
                    cout<<ProcessAffinityMask<<endl;    //0x0001
                    cout<<SystemAffinityMask<<endl;        //0x0001
                
                    AllowProcessAffinity = ProcessAffinityMask & SystemAffinityMask;
                    cout<<AllowProcessAffinity<<endl;
                }
            
                LARGE_INTEGER Freq;
                typedef vector<LARGE_INTEGER> FreqVec_type;
                FreqVec_type FreqVec;
                
                while(FreqVec.size() != 5)
                {
                    if(QueryPerformanceFrequency(&Freq))
                    {
                        DisplayFrequency(cout, Freq);
                        FreqVec.push_back(Freq);
                    }
                    Sleep(1000);
                }
            
                for(FreqVec_type::iterator iter = FreqVec.begin(); iter!=FreqVec.end(); ++iter)
                {
                    DisplayFrequency(cout, *iter);
                }
            
                cout<<"---------------------"<<endl;
            
                //calculate the timeSpan;
                TimeSpan ts;
                int sleepTime(3123);
            
                ts.Frequency = &Freq;
            
                if(QueryPerformanceCounter(&ts.StartCounter))
                {
                    ts.HAS_ERROR = false;
                    Sleep(sleepTime);
                }
                if(!ts.HAS_ERROR)
                {
                    QueryPerformanceCounter(&ts.StopCounter);
                }
                
                cout<<ts.CalTimeSpan()<<endl;
                cout<<(ts.StopCounter.QuadPart-ts.StartCounter.QuadPart)/sleepTime<<endl;
            
                return 0;
            }
            
            void DisplayFrequency(ostream &out, LARGE_INTEGER &freq)
            {
                out<<"start display!"<<endl;
                out<<freq.HighPart<<endl;
                out<<freq.LowPart<<endl;
                out<<freq.QuadPart<<endl;
                out<<"end display!"<<endl;
            }
            
            

            推薦文檔:《使用增強的計時器測量代碼段》(下載可適合打印,已排版,閱讀該文檔需要使用Microsoft Word 2007或相關閱讀器(后綴docx),如您需要pdf文檔,可以給我留言,我會將它發給你,在CSDN的下載中,您可能需要注冊成為相關網站的會員,或者使用積分,如果您覺得麻煩,可以直接向我索取!點此獲取!

            posted on 2009-02-19 01:49 volnet 閱讀(649) 評論(0)  編輯 收藏 引用

            特殊功能
             
            国产免费久久久久久无码| 91麻豆国产精品91久久久| 波多野结衣久久精品| 伊人久久大香线蕉精品| 国产精品青草久久久久婷婷| 亚洲另类欧美综合久久图片区| 久久播电影网| 久久久久国产日韩精品网站| 久久久WWW免费人成精品| 久久亚洲欧洲国产综合| 久久99热这里只频精品6| 国内精品久久久久影院亚洲| 久久只这里是精品66| 色妞色综合久久夜夜| 色综合久久综合中文综合网| 午夜天堂av天堂久久久| 久久亚洲精品国产精品| 久久精品国产99国产电影网| 国产精品99久久久久久董美香| 久久久久亚洲AV成人网人人网站 | 国产成人精品久久| 久久精品国产亚洲77777| 国产∨亚洲V天堂无码久久久| 国产精品成人99久久久久 | 久久青草国产精品一区| 精品国产综合区久久久久久| 日本高清无卡码一区二区久久| 久久久高清免费视频| 国产精品免费福利久久| 久久久中文字幕日本| 久久精品一本到99热免费| 久久午夜福利电影| 久久久久久亚洲AV无码专区| 精品久久久久久国产免费了| 亚洲乱码中文字幕久久孕妇黑人| 久久精品中文字幕久久| 亚洲欧洲日产国码无码久久99 | 国产成人精品白浆久久69| 99久久国产综合精品成人影院| 久久国产欧美日韩精品| 亚洲Av无码国产情品久久|