// 计算程序执行时间.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;
}
计算一段程序的执行时间
最新推荐文章于 2022-03-30 21:27:37 发布