当前位置: 技术问答>linux和unix
获取处理时间(准确到毫秒)
来源: 互联网 发布时间:2015-05-25
本文导语: 要得到一段代码运行时间(可能在阻塞状态,但是一定会返回),用什么函数? | /* Get the current time of day and timezone information, putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. Returns 0 o...
要得到一段代码运行时间(可能在阻塞状态,但是一定会返回),用什么函数?
|
/* Get the current time of day and timezone information,
putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
Returns 0 on success, -1 on errors.
NOTE: This form of timezone information is obsolete.
Use the functions and variables declared in instead. */
extern int gettimeofday (struct timeval *__restrict __tv,
__timezone_ptr_t __tz) __THROW;
putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
Returns 0 on success, -1 on errors.
NOTE: This form of timezone information is obsolete.
Use the functions and variables declared in instead. */
extern int gettimeofday (struct timeval *__restrict __tv,
__timezone_ptr_t __tz) __THROW;
|
代码运行前用gettimeofday()取得系统时间并纪录,代码运行
后再用gettimeofday()取得系统时间,两者相减就是代码运行
时间。
后再用gettimeofday()取得系统时间,两者相减就是代码运行
时间。