3,881
社区成员
发帖
与我相关
我的任务
分享#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;
} #include<iostream>
#include<ctime>
using namespace std;
int main()
{
time_t begin,end;
begin=clock();
//这里加上你的代码
end=clock();
cout<<"runtime: "<<double(end-begin)/CLOCKS_PER_SEC<<endl;
return 0;
} #include <sys/times.h>
clock_t times(struct tms *buf);
struct tms {
clock_t tms_utime; /* 用户时间 */
clock_t tms_stime; /* 系统时间 */
clock_t tms_cutime; /* 子进程的用户时间 */
clock_t tms_cstime; /* 子进程的系统时间 */
};