您的位置:首页 > 其它

一个程序运行计时方法

2009-06-29 22:18 225 查看
#include <ctime>
#include <iostream>
using namespace std;

int main(int argc,char** argv)
{
long x=0;

long s,e;
double costtime;

s = clock();
for ( int n=0; n<100000000; n++ )
{
x++;
}
e = clock();

costtime = (double)(e-s)/1000;  //转换时间格式
cout<<"花费时间:"<<costtime<<"s"<<endl;

getchar();
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: