获取本地时间戳信息
time_t Get_Timestamp(int accuracy = 1) //0:s,1:ms,2:us,3:ns
{
struct timespec tv;
clock_gettime(CLOCK_REALTIME, &tv);
switch (accuracy)
{
case 0:
return tv.tv_sec;
case 1:
return tv.tv_sec * 1000 + tv.tv_nsec / 1000000;
case 2:
return tv.tv_sec * 1000000 + tv.tv_nsec / 1000;
case 3:
return tv.tv_sec * 1000000000 + tv.tv_nsec;
default:
return tv.tv_sec;
}
}
uint64_t time_now = (uint64_t)Get_Timestamp(3);
printf("\ntime_start frame:%ld\n",time_now);
uint64_t time_now = (uint64_t)Get_Timestamp(3);
printf("\ntime_stop frame:%ld\n",time_now);