linux的時間函數

時間分類
1 cpu time(clock_t)
2 calendar time(time_t),三種形式如下:
        1 value time
        2 broken-down time
        3 string time
<time.h>
1 time_t time( time_t *calptr )
2 struct tm *gmtime( const time_t *calptr )
3 struct tm *localtime( const time_t *calptr )
4 time_t mktime( struct tm *tmptr )
5 size_t strftime( char *buf, size_t maxsize, const char *format, const struct tm *tmptr )
6 char *strptime( const char* buf, const char* format, struct tm* tmptr )
7 clock_t clock( void ),轉換單位是CLOCKS_PER_SEC
<sys/time.h>
1 int gettimeofday( struct timeval *restrict tp, void *tzp )
2 int clock_gettime( clockid_t clock_id, struct timespec *tsp )
<sys/times.h>
1 clock_t times( struct tms *buf ),轉換單位是sysconf( _SC_CLK_TCK ),增強版的clock()

最后來一張APUE的時間函數轉換圖


time.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。