C++ 自然归并排序
设置PSPad调用Mingw编译

C++ 精确计算运行时间

scturtle posted @ 2009年11月05日 03:50 in Other , 1835 阅读

最近在宿舍老是不能上网,非常郁闷……还是好好看书吧

做着实验,搜了半天,好歹找个看得懂了

#include <windows.h>
#include <iostream>
using namespace std;

int main()
{
    int jingDu=10000000;
    LARGE_INTEGER frequency,nStartCounter,nStopCounter;
    QueryPerformanceFrequency(&frequency);

    QueryPerformanceCounter(&nStartCounter);

    for(int i=0; i< 100; i++)
        cout << i << endl;

    QueryPerformanceCounter(&nStopCounter);

    double time=((nStopCounter.QuadPart - nStartCounter.QuadPart) * jingDu)/frequency.QuadPart;

    cout << "i lives " << time/jingDu << " second" << endl;
//    TCHAR buffer[100];
//    wsprintf(buffer,"執行時間 %d millisecond ",time);
//    MessageBox(NULL,buffer,"計算時間",MB_OK);
}

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter