当前位置: 技术问答>linux和unix
如何获得程序自身的"kernel time"和"user time"?
来源: 互联网 发布时间:2016-03-27
本文导语: 我记得task_struct里有这些属性,但是怎么调用它们呢? 谢谢。 | E times - get process and waited-for child process times SYNOPSIS #include clock_t times(struct tms *buffer); ...
我记得task_struct里有这些属性,但是怎么调用它们呢?
谢谢。
谢谢。
|
E
times - get process and waited-for child process times
SYNOPSIS
#include
clock_t times(struct tms *buffer);
DESCRIPTION
The times() function shall fill the tms structure pointed to by buffer with time-accounting information. The tms
structure is defined in .
All times are measured in terms of the number of clock ticks used.
The times of a terminated child process shall be included in the tms_cutime and tms_cstime elements of the parent
when wait() or waitpid() returns the process ID of this terminated child. If a child process has not waited for its
children, their times shall not be included in its times.
* The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling
process.
* The tms_stime structure member is the CPU time charged for execution by the system on behalf of the calling pro-
cess.
* The tms_cutime structure member is the sum of the tms_utime and tms_cutime times of the child processes.
* The tms_cstime structure member is the sum of the tms_stime and tms_cstime times of the child processes.
times - get process and waited-for child process times
SYNOPSIS
#include
clock_t times(struct tms *buffer);
DESCRIPTION
The times() function shall fill the tms structure pointed to by buffer with time-accounting information. The tms
structure is defined in .
All times are measured in terms of the number of clock ticks used.
The times of a terminated child process shall be included in the tms_cutime and tms_cstime elements of the parent
when wait() or waitpid() returns the process ID of this terminated child. If a child process has not waited for its
children, their times shall not be included in its times.
* The tms_utime structure member is the CPU time charged for the execution of user instructions of the calling
process.
* The tms_stime structure member is the CPU time charged for execution by the system on behalf of the calling pro-
cess.
* The tms_cutime structure member is the sum of the tms_utime and tms_cutime times of the child processes.
* The tms_cstime structure member is the sum of the tms_stime and tms_cstime times of the child processes.
|
struct tms {
clock_t tms_utime; /* user time */
clock_t tms_stime; /* system time */
clock_t tms_cutime; /* user time of children */
clock_t tms_cstime; /* system time of children */
};
clock_t tms_utime; /* user time */
clock_t tms_stime; /* system time */
clock_t tms_cutime; /* user time of children */
clock_t tms_cstime; /* system time of children */
};