OSDN Git Service

Convert release and draft pages to UTF-8.
[linuxjm/jm.git] / manual / LDP_man-pages / release / 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 .\"
28 .\" Japanese Version Copyright (c) 1996 Hiroaki Nagoya
29 .\"         all rights reserved.
30 .\" Translated Mon Feb  3 15:35:19 JST 1997
31 .\"         by Hiroaki Nagoya <nagoya@is.titech.ac.jp>
32 .\" Updated Fri Sep 27 JST 2002 by Kentaro Shirakata <argrath@ub32.org>
33 .\" Updated 2007-05-28, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.48
34 .\"
35 .\"WORD: processor time   プロセッサ時間
36 .\"WORD: CPU time         CPU時間
37 .\"
38 .TH CLOCK 3  2008-08-28 "GNU" "Linux Programmer's Manual"
39 .SH 名前
40 clock \- プロセッサ時間の取得
41 .SH 書式
42 .nf
43 .B #include <time.h>
44 .sp
45 .B clock_t clock(void);
46 .fi
47 .SH 説明
48 .BR clock ()
49 はプログラムの使用したプロセッサ時間の近似値を返す。
50 .SH 返り値
51 返り値は
52 .I clock_t
53 単位での CPU 時間である。
54 秒単位での値を得るためには
55 .B CLOCKS_PER_SEC
56 で割ればよい。
57 使用したプロセッサ時間が得られない場合や、その値を表現できない場合、
58 この関数は
59 .I (clock_t)\ \-1
60 を返す。
61 .SH 準拠
62 C89, C99, POSIX.1-2001.
63 POSIX は実際の精度にはよらず
64 .B CLOCKS_PER_SEC
65 が 1000000 であることを要求している。
66 .SH 注意
67 C の標準規格ではプログラムの開始の時点ではどんな値が返ってきても
68 かまわない。
69 移植性を最大限確保するためには、プログラムの開始時に
70 .BR clock ()
71 を呼び出してその値を差し引くこと。
72 .PP
73 時刻は桁あふれする可能性がある点に注意すること。
74 .B CLOCKS_PER_SEC
75 が 1000000 である 32 ビットシステムでは、
76 この関数は約 72 分毎に同じ値を返すことになる。
77 .PP
78 実装によっては、
79 .BR clock ()
80 で返される値に
81 .BR wait (2)
82 (あるいはその他の wait のような関数) で収集された
83 子プロセスの時間が含まれる場合もある。
84 Linux では、
85 .BR clock ()
86 が返す値には wait された子プロセスの時間は含まれない。
87 .\" I have seen this behavior on Irix 6.3, and the OSF/1, HP/UX, and
88 .\" Solaris manual pages say that clock() also does this on those systems.
89 .\" POSIX.1-2001 doesn't explicitly allow this, nor is there an
90 .\" explicit prohibition. -- MTK
91 .BR times (2)
92 関数は呼び出し元とその子プロセスに関する情報を
93 (別々に) 明示的に返すので、より好ましいだろう。
94 .SH 関連項目
95 .BR clock_gettime (2),
96 .BR getrusage (2),
97 .BR times (2)