定义函数
#include <sys/resource.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
class Util
{
public:
static double millitime()
{
struct timeval tv;
struct timezone tz;
gettimeofday(&tv, &tz);
return tv.tv_sec + tv.tv_usec / 1000000.00;
}
};
使用时
int aveNonuniform(int arg,const char**args){
double start,end;
start=Util::millitime();
/*
代码
*/
end=Util::millitime();
cout<<"aveNonuni time is "<<end-start<<endl;
return 0;
}