1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Modified Sat Jul 24 21:27:01 1993 by Rik Faith (faith@cs.unc.edu)
6 .\" Modified 14 Jun 2002, Michael Kerrisk <mtk.manpages@gmail.com>
7 .\" Added notes on differences from other UNIX systems with respect to
8 .\" waited-for children.
9 .TH clock 3 (date) "Linux man-pages (unreleased)"
11 clock \- determine processor time
14 .RI ( libc ", " \-lc )
19 .B clock_t clock(void);
24 function returns an approximation of processor time used by the program.
26 The value returned is the CPU time used so far as a
28 to get the number of seconds used, divide by
30 If the processor time used is not available or its value cannot
31 be represented, the function returns the value
34 For an explanation of the terms used in this section, see
42 Interface Attribute Value
45 T} Thread safety MT-Safe
51 POSIX.1-2001, POSIX.1-2008, C89, C99.
54 equals 1000000 independent
55 of the actual resolution.
57 The C standard allows for arbitrary values at the start of the program;
58 subtract the value returned from a call to
60 at the start of the program to get maximum portability.
62 Note that the time can wrap around.
63 On a 32-bit system where
65 equals 1000000 this function will return the same
66 value approximately every 72 minutes.
68 On several other implementations,
71 also includes the times of any children whose status has been
74 (or another wait-type call).
75 Linux does not include the times of waited-for children in the
78 .\" I have seen this behavior on Irix 6.3, and the OSF/1, HP/UX, and
79 .\" Solaris manual pages say that clock() also does this on those systems.
80 .\" POSIX.1-2001 doesn't explicitly allow this, nor is there an
81 .\" explicit prohibition. -- MTK
84 function, which explicitly returns (separate) information about the
85 caller and its children, may be preferable.
87 In glibc 2.17 and earlier,
89 was implemented on top of
91 For improved accuracy,
92 since glibc 2.18, it is implemented on top of
95 .B CLOCK_PROCESS_CPUTIME_ID
98 .BR clock_gettime (2),