Go to the first, previous, next, last section, table of contents.


Detailed Elapsed CPU Time Inquiry

The times function returns more detailed information about elapsed processor time in a struct tms object. You should include the header file `sys/times.h' to use this facility.

Data Type: struct tms
The tms structure is used to return information about process times. It contains at least the following members:

clock_t tms_utime
This is the CPU time used in executing the instructions of the calling process.
clock_t tms_stime
This is the CPU time used by the system on behalf of the calling process.
clock_t tms_cutime
This is the sum of the tms_utime values and the tms_cutime values of all terminated child processes of the calling process, whose status has been reported to the parent process by wait or waitpid; see section Process Completion. In other words, it represents the total CPU time used in executing the instructions of all the terminated child processes of the calling process, excluding child processes which have not yet been reported by wait or waitpid.
clock_t tms_cstime
This is similar to tms_cutime, but represents the total CPU time used by the system on behalf of all the terminated child processes of the calling process.

All of the times are given in clock ticks. These are absolute values; in a newly created process, they are all zero. See section Creating a Process.

Function: clock_t times (struct tms *buffer)
The times function stores the processor time information for the calling process in buffer.

The return value is the same as the value of clock(): the elapsed real time relative to an arbitrary base. The base is a constant within a particular process, and typically represents the time since system start-up. A value of (clock_t)(-1) is returned to indicate failure.

Portability Note: The clock function described in section Basic CPU Time Inquiry, is specified by the ISO C standard. The times function is a feature of POSIX.1. In the GNU system, the value returned by the clock function is equivalent to the sum of the tms_utime and tms_stime fields returned by times.


Go to the first, previous, next, last section, table of contents.