- 论坛徽章:
- 0
|
#include <sys/time.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
//#include <math.h>
void function()
{
unsigned int i,j;
double y;
for(i = 0; i<100;j++)
for(j = 0;j <100;j++)
y = i+j;
return ;
}
int main()
{
int res;
struct timeval tpstart,tpend;
float timeuse;
printf("There is right");
res = gettimeofday(&tpstart,NULL);
if(res == -1)
{
printf("There is wrong");
exit(1);
}
function();
gettimeofday(&tpend,NULL);
timeuse = 1000000*(tpend.tv_sec-tpstart.tv_sec)+
tpend.tv_usec-tpstart.tv_usec;
timeuse/=1000000;
printf("Used time:%f\n",timeuse);
exit(0);
}
这个程序编译后执行,没有任何的输出,好像是一直卡在那儿了。不知道哪儿出错了,感觉第一个printf应该输出出来才是啊?高人指点一下。 |
|