• <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 閱讀(660) 評論(0)  編輯 收藏 引用

            特殊功能
             
            久久99精品免费一区二区| 97久久超碰国产精品2021| 久久99热这里只有精品66| 久久一日本道色综合久久| 丰满少妇人妻久久久久久4| 久久无码高潮喷水| 亚洲国产精品久久久久网站 | 久久电影网| 久久精品中文字幕无码绿巨人| 日韩一区二区久久久久久 | 欧美成a人片免费看久久| 久久久精品午夜免费不卡| 亚洲国产成人久久综合一区77| 99久久99这里只有免费的精品| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 久久精品夜色噜噜亚洲A∨| 久久精品成人国产午夜| 亚洲精品午夜国产VA久久成人 | 91久久香蕉国产熟女线看| 欧美噜噜久久久XXX| 久久久久久青草大香综合精品| 72种姿势欧美久久久久大黄蕉| 亚洲AV无码一区东京热久久| 久久丫忘忧草产品| 亚洲国产香蕉人人爽成AV片久久 | 久久午夜福利电影| 精品国产青草久久久久福利| 亚洲一区中文字幕久久| 99久久免费国产精品| 精品欧美一区二区三区久久久| 伊人久久免费视频| 国产精品免费久久| 日本久久久久久中文字幕| 狠狠色丁香久久综合五月| 国内精品九九久久久精品| 日本欧美久久久久免费播放网| 中文字幕久久精品无码| 精品国际久久久久999波多野| 国产精品久久久久久影院| 国产精品美女久久久久av爽| 伊人久久大香线蕉综合网站|