首页 > 代码库 > linux timing

linux timing

double getUnixTime(void){    struct timespec tv;    if(clock_gettime(CLOCK_REALTIME, &tv) != 0) return 0;    return (((double) tv.tv_sec) + (double) (tv.tv_nsec / 1000000000.0));}double start_time = getUnixTime();double stop_time, difference;algorithm();stop_time = getUnixTime();difference = stop_time - start_time;

g++ t.c++ -lrt