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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。