C++程序运行时间计算(二)

#include "hptime.h"
#include <iostream>
#include <Windows.h>
#include <time.h>
#include <cmath>
using namespace std;

void CalcTime()
{
 unsigned long diff = 10000000;
 while(diff > 0)
 {
  --diff;
 }
 Sleep(1000);
}

 

int main()
{
 clock_t start, end;
 start = clock();

 CalcTime();
 end = clock();

 int tm =difftime(end, start);
 cout << tm << endl;
 int wait;
 cin >> wait;
 
    return 0;
}

posted @ 2013-08-28 21:43  Predator  阅读(182)  评论(0编辑  收藏  举报