欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

C語言

當(dāng)前位置:主頁 > 軟件編程 > C語言 >

c++利用windows函數(shù)實(shí)現(xiàn)計(jì)時(shí)示例

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語言|點(diǎn)擊: 次

復(fù)制代碼 代碼如下:

//Windows系統(tǒng)下可以用 time(),clock(),timeGetTime(),GetTickCount(),QueryPerformanceCounter()來對一段程序代碼進(jìn)行計(jì)時(shí)

#include <stdio.h>
#include <windows.h>
#include <time.h>                   //time_t time()  clock_t clock()   
#include <Mmsystem.h>               //timeGetTime()   
#pragma comment(lib, "Winmm.lib")   //timeGetTime()   

//使用方法:將Sleep()函數(shù)換成需要測試運(yùn)行時(shí)間的函數(shù)即可。

int main()
{   //用time()來計(jì)時(shí),以秒為單位
    time_t timeBegin, timeEnd;
    timeBegin = time(NULL);
    Sleep(1000);
    timeEnd = time(NULL);
    printf("%d\n", timeEnd - timeBegin);


    //用clock()來計(jì)時(shí),以毫秒為單位
    clock_t  clockBegin, clockEnd;
    clockBegin = clock();
    Sleep(800);
    clockEnd = clock();
    printf("%d\n", clockEnd - clockBegin);


    //用timeGetTime()來計(jì)時(shí),以毫秒為單位
    DWORD  dwBegin, dwEnd;
    dwBegin = timeGetTime();
    Sleep(800);
    dwEnd = timeGetTime();
    printf("%d\n", dwEnd - dwBegin);


    //用GetTickCount()來計(jì)時(shí),以毫秒為單位
    DWORD  dwGTCBegin, dwGTCEnd;
    dwGTCBegin = GetTickCount();
    Sleep(800);
    dwGTCEnd = GetTickCount();
    printf("%d\n", dwGTCEnd - dwGTCBegin);


    //用QueryPerformanceCounter()來計(jì)時(shí),以微秒為單位
    LARGE_INTEGER  large_interger;
    double dff;
    __int64  c1, c2;
    QueryPerformanceFrequency(&large_interger);
    dff = large_interger.QuadPart;
    QueryPerformanceCounter(&large_interger);
    c1 = large_interger.QuadPart;
    Sleep(800);
    QueryPerformanceCounter(&large_interger);
    c2 = large_interger.QuadPart;
    printf("本機(jī)高精度計(jì)時(shí)器頻率%lf\n", dff);
    printf("第一次計(jì)時(shí)器值%I64d\n第二次計(jì)時(shí)器值%I64d\n計(jì)時(shí)器差%I64d\n", c1, c2, c2 - c1);
    printf("計(jì)時(shí)%lf毫秒\n\n", (c2 - c1) * 1000 / dff);
    return 0;
}



網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有