.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" License. .\" Modified Sat Jul 24 21:27:01 1993 by Rik Faith (faith@cs.unc.edu) .\" Modified 14 Jun 2002, Michael Kerrisk .\" Added notes on differences from other UNIX systems with respect to .\" waited-for children. .\" .\" Japanese Version Copyright (c) 1996 Hiroaki Nagoya .\" all rights reserved. .\" Tranlated Mon Feb 3 15:35:19 JST 1997 .\" by Hiroaki Nagoya .\" Updated Fri Sep 27 JST 2002 by Kentaro Shirakata .\" Updated 2007-05-28, Akihiro MOTOKI , LDP v2.48 .\" .\"WORD: processor time プロセッサ時間 .\"WORD: CPU time CPU時間 .\" .TH CLOCK 3 2008-08-28 "GNU" "Linux Programmer's Manual" .SH 名前 clock \- プロセッサ時間の取得 .SH 書式 .nf .B #include .sp .B clock_t clock(void); .fi .SH 説明 .BR clock () はプログラムの使用したプロセッサ時間の近似値を返す。 .SH 返り値 返り値は .I clock_t 単位での CPU 時間である。 秒単位での値を得るためには .B CLOCKS_PER_SEC で割ればよい。 使用したプロセッサ時間が得られない場合や、その値を表現できない場合、 この関数は .I (clock_t)\ \-1 を返す。 .SH 準拠 C89, C99, POSIX.1-2001. POSIX は実際の精度にはよらず .B CLOCKS_PER_SEC が 1000000 であることを要求している。 .SH 注意 C の標準規格ではプログラムの開始の時点ではどんな値が返ってきても かまわない。 移植性を最大限確保するためには、プログラムの開始時に .BR clock () を呼び出してその値を差し引くこと。 .PP 時刻は桁あふれする可能性がある点に注意すること。 .B CLOCKS_PER_SEC が 1000000 である 32 ビットシステムでは、 この関数は約 72 分毎に同じ値を返すことになる。 .PP 実装によっては、 .BR clock () で返される値に .BR wait (2) (あるいはその他の wait のような関数) で収集された 子プロセスの時間が含まれる場合もある。 Linux では、 .BR clock () が返す値には wait された子プロセスの時間は含まれない。 .\" I have seen this behavior on Irix 6.3, and the OSF/1, HP/UX, and .\" Solaris manual pages say that clock() also does this on those systems. .\" POSIX.1-2001 doesn't explicitly allow this, nor is there an .\" explicit prohibition. -- MTK .BR times (2) 関数は呼び出し元とその子プロセスに関する情報を (別々に) 明示的に返すので、より好ましいだろう。 .SH 関連項目 .BR clock_gettime (2), .BR getrusage (2), .BR times (2)