Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

times - get process times

&pagelevel(4)&pagelevel

Syntax

#include <sys/times.h>

clock_t times(struct tms *buffer) ;

Description times() fills the tms structure pointed to by buffer with information on execution times (see

sys/times.h).

All time specifications are defined in terms of the number of clock ticks used.

The execution times of a terminated child process are included in the tms_cutime and
tms_cstime components of the parent process when the wait() function returns the
process ID of the terminated child process. If a child process does not wait for its children,
their times are not included.

  • The tms_utime structure member is the CPU time used for the execution of user
    instructions of the calling process.

  • The tms_stime structure member is the CPU time used for the execution of system
    statements on behalf of the calling process.

  • 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.

Return val.

Elapsed real time, in clock ticks, since a particular point in time

(e.g. since the system was activated). This point in time does not change
from one times() function call within a process to another. The value
returned may exceed the possible value range of type clock_t (overflow).

(clock_t)-1

if an error occurs. errno is set to indicate the error.

Notes

Portable applications should use the function sysconf(_SC_CLK_TCLK) to determine the
number of clock ticks per second, since this value may vary from system to system.

See also

exec, fork(), sysconf(), time(), wait(), sys/times.h.