示例代码:
long begin,end;
double time;
begin = clock();
{
//查看代码
}
end = clock();
time = (double)(end - begin) / CLOCKS_PER_SEC;
Logger->Info( "%f seconds\n", time );
其他参考:
#include<iostream>
include<windows.h>
using namespace std;
int main()
{
DWORD start_time=GetTickCount();
{
//此处为被测试代码
}
DWORD end_time=GetTickCount();
cout<<"The run time is:"<<(end_time-start_time)<<"ms!"<<endl;//输出运行时间
return 0;
}
#include<iostream>
#include<time.h>
using namespace std;
int main()
{
clock_t start_time=clock();
{
//被测试代码
}
clock_t end_time=clock();
cout<< "Running time is: "<<static_cast<double>(end_time- start_time)/CLOCKS_PER_SEC*1000<<"ms"<<endl;//输出运行时间
return 0;
}
posted on 2013-10-22 08:20
王海光 阅读(821)
评论(0) 编辑 收藏 引用 所属分类:
C++