您的位置:首页 > 其它

计算一段程序的执行时间

2013-07-01 11:27 411 查看
// 计算程序执行时间.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <time.h>
void do_something()
{
for(int i=0;i<100000;i++)
for(int j=0;j<10000;j++)
;
}
int main(int arg,char ** argv)
{
clock_t start=clock();
do_something();
clock_t end=clock();
float time=(float)(end-start)/CLOCKS_PER_SEC;
printf("%fs\n",time);
system("pause");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: