头文件:<sys/times.h>
原型:
clock_t times(struct tms *buf);
正确返回墙上时钟经过时间, 出错返回-1 ;可精确统计程序代码运行时间,区分用户态与内核态耗时。
其中参数类型struct tms为:
struct tms
{
clock_t tms_utime; //用户CPU时间
clock_t tms_stime; //系统CPU时间
clock_t tms_cutime; //以终止子进程的用户CPU时间
clock_t tms_cstime; //已终止子进程的系统CPU时间
};