#include <sys/time.h>
/**//*struct timeval { */
//long tv_sec; /* 秒数 */
//long tv_usec; /* 微秒数 */
//};
//int gettimeofday(struct timeval *tv,struct timezone *tz);
//gettimeofday将时间保存在结构tv之中.tz一般我们使用NULL来代替.
#include <sys/time.h>
#include <stdio.h>
#include <math.h>
int matrix[1023][15];
const char *str = "this is a str";
int main()
{
int i,j,sum=0;
struct timeval tpstart,tpend;
float timeuse;
gettimeofday(&tpstart,NULL);
//code MY:+++++++++++++++++++++++++++++++++
for(i=0;i<1023;i++){
for(j=0;j<15;j++){
sum+=matrix[i][j];
}
}
sum+=strlen(str)*15*1023;
//+++++++++++++++++++++++++++++++++++++++++
gettimeofday(&tpend,NULL);
timeuse=1000000*(tpend.tv_sec-tpstart.tv_sec)+
tpend.tv_usec-tpstart.tv_usec;
timeuse/=1000000;
printf("Used Time:%fn\n",timeuse);
return 0;
}