1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified Sat Jul 24 21:27:01 1993 by Rik Faith (faith@cs.unc.edu)
26 .\" Modified 14 Jun 2002, Michael Kerrisk <mtk.manpages@gmail.com>
27 .\" Added notes on differences from other UNIX systems with respect to
28 .\" waited-for children.
29 .TH CLOCK 3 2021-03-22 "GNU" "Linux Programmer's Manual"
31 clock \- determine processor time
36 .B clock_t clock(void);
41 function returns an approximation of processor time used by the program.
43 The value returned is the CPU time used so far as a
45 to get the number of seconds used, divide by
47 If the processor time used is not available or its value cannot
48 be represented, the function returns the value
51 For an explanation of the terms used in this section, see
59 Interface Attribute Value
62 T} Thread safety MT-Safe
68 POSIX.1-2001, POSIX.1-2008, C89, C99.
71 equals 1000000 independent
72 of the actual resolution.
74 The C standard allows for arbitrary values at the start of the program;
75 subtract the value returned from a call to
77 at the start of the program to get maximum portability.
79 Note that the time can wrap around.
80 On a 32-bit system where
82 equals 1000000 this function will return the same
83 value approximately every 72 minutes.
85 On several other implementations,
88 also includes the times of any children whose status has been
91 (or another wait-type call).
92 Linux does not include the times of waited-for children in the
95 .\" I have seen this behavior on Irix 6.3, and the OSF/1, HP/UX, and
96 .\" Solaris manual pages say that clock() also does this on those systems.
97 .\" POSIX.1-2001 doesn't explicitly allow this, nor is there an
98 .\" explicit prohibition. -- MTK
101 function, which explicitly returns (separate) information about the
102 caller and its children, may be preferable.
104 In glibc 2.17 and earlier,
106 was implemented on top of
108 For improved accuracy,
109 since glibc 2.18, it is implemented on top of
110 .BR clock_gettime (2)
112 .BR CLOCK_PROCESS_CPUTIME_ID
115 .BR clock_gettime (2),