#include <sys/time.h>   //引入头文件
int main()
{
struct timeval t1,t2;
double timeuse;
gettimeofday(&t1,NULL);

fun();

gettimeofday(&t2,NULL);
timeuse = (t2.tv_sec - t1.tv_sec) + (double)(t2.tv_usec - t1.tv_usec)/1000000.0;

cout<<"time = "<<timeuse<<endl; //输出时间(单位:s)
}