OSDN Git Service

(split) LDP man-pages の original/ を v3.29 に更新。
[linuxjm/LDP_man-pages.git] / original / man3 / clock.3
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\" License.
23 .\" Modified Sat Jul 24 21:27:01 1993 by Rik Faith (faith@cs.unc.edu)
24 .\" Modified 14 Jun 2002, Michael Kerrisk <mtk.manpages@gmail.com>
25 .\"     Added notes on differences from other UNIX systems with respect to
26 .\"     waited-for children.
27 .TH CLOCK 3  2008-08-28 "GNU" "Linux Programmer's Manual"
28 .SH NAME
29 clock \- Determine processor time
30 .SH SYNOPSIS
31 .nf
32 .B #include <time.h>
33 .sp
34 .B clock_t clock(void);
35 .fi
36 .SH DESCRIPTION
37 The
38 .BR clock ()
39 function returns an approximation of processor time used by the program.
40 .SH "RETURN VALUE"
41 The value returned is the CPU time used so far as a
42 .IR clock_t ;
43 to get the number of seconds used, divide by
44 .BR CLOCKS_PER_SEC .
45 If the processor time used is not available or its value cannot
46 be represented, the function returns the value
47 .IR (clock_t)\ \-1 .
48 .SH "CONFORMING TO"
49 C89, C99, POSIX.1-2001.
50 POSIX requires that
51 .B CLOCKS_PER_SEC
52 equals 1000000 independent
53 of the actual resolution.
54 .SH NOTES
55 The C standard allows for arbitrary values at the start of the program;
56 subtract the value returned from a call to
57 .BR clock ()
58 at the start of the program to get maximum portability.
59 .PP
60 Note that the time can wrap around.
61 On a 32-bit system where
62 .B CLOCKS_PER_SEC
63 equals 1000000 this function will return the same
64 value approximately every 72 minutes.
65 .PP
66 On several other implementations,
67 the value returned by
68 .BR clock ()
69 also includes the times of any children whose status has been
70 collected via
71 .BR wait (2)
72 (or another wait-type call).
73 Linux does not include the times of waited-for children in the
74 value returned by
75 .BR clock ().
76 .\" I have seen this behavior on Irix 6.3, and the OSF/1, HP/UX, and
77 .\" Solaris manual pages say that clock() also does this on those systems.
78 .\" POSIX.1-2001 doesn't explicitly allow this, nor is there an
79 .\" explicit prohibition. -- MTK
80 The
81 .BR times (2)
82 function, which explicitly returns (separate) information about the
83 caller and its children, may be preferable.
84 .SH "SEE ALSO"
85 .BR clock_gettime (2),
86 .BR getrusage (2),
87 .BR times (2)