linux 时间函数:
time/time_t 秒
ftime/ struct timeb 毫秒
gettimeofday/struct timeval us
clock_gettime/ struct timespec ns
gmtime/localtime/timegm/mktime/strftime/struct tm
其中
time 精度低,
ftime 已废弃,
clock_gettime 系统调用,精度高
gettimeofday vsyscall ,系统态, 开销低
定时函数,用于让程序等待一段时间或安排计划任务:
- sleep
- alarm
- usleep
- nanosleep
- clock_nanosleep
- getitimer / setitimer
- timer_create / timer_settime / timer_gettime / timer_delete
- timerfd_create / timerfd_gettime / timerfd_settime
来源: http://www.cppblog.com/Solstice/archive/2014/08/21/139769.html
时间: 2024-10-30 09:52:52