1. 使用clock_gettime接口即可
2. clock_gettime的使用方法:
2.1 定義一個結構體
struct timespec ts;
2.2 調用clock_gettime獲取當前時間戳
clock_gettime(CLOCK_MONOTONIC, &ts);
2.3 打印時間戳
printf("<%d.%d>\n",ts.tv_sec,ts.tv_nsec);
3. 加上此接口后編譯鏈接時需要加上librt庫,因為clock_gettime包含在librt庫中
gcc myprog.c -o myprog -lrt