linux的时间函数

2019-07-19  本文已影响0人  小胖_20c7
时间分类
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
上一篇下一篇

猜你喜欢

热点阅读