.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de) .\" .\" %%%LICENSE_START(VERBATIM) .\" 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_END .\" .\" 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. .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1996 Hiroaki Nagoya .\" all rights reserved. .\" Translated 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 .\" .TH CLOCK 3 2013\-08\-19 GNU "Linux Programmer's Manual" .SH 名前 clock \- プロセッサ時間の取得 .SH 書式 .nf \fB#include \fP .sp \fBclock_t clock(void);\fP .fi .SH 説明 \fBclock\fP() はプログラムの使用したプロセッサ時間の近似値を返す。 .SH 返り値 返り値は \fIclock_t\fP 単位での CPU 時間である。 秒単位での値を得るためには \fBCLOCKS_PER_SEC\fP で割ればよい。 使用したプロセッサ時間が得られない場合や、その値を表現できない場合、 この関数は \fI(clock_t)\ \-1\fP を返す。 .SH 準拠 C89, C99, POSIX.1\-2001. POSIX は実際の精度にはよらず \fBCLOCKS_PER_SEC\fP が 1000000 であることを要求している。 .SH 注意 C の標準規格ではプログラムの開始の時点ではどんな値が返ってきても かまわない。 移植性を最大限確保するためには、プログラムの開始時に \fBclock\fP() を呼び出してその値を差し引くこと。 .PP 時刻は桁あふれする可能性がある点に注意すること。 \fBCLOCKS_PER_SEC\fP が 1000000 である 32 ビットシステムでは、 この関数は約 72 分毎に同じ値を返すことになる。 .PP .\" 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 実装によっては、 \fBclock\fP() で返される値に \fBwait\fP(2) (あるいはその他の wait のような関数) で収集された 子プロセスの時間が含まれる場合もある。 Linux では、 \fBclock\fP() が返す値には wait された子プロセスの時間は含まれない。 \fBtimes\fP(2) 関数は呼び出し元とその子プロセスに関する情報を (別々に) 明示的に返すので、より好ましいだろう。 glibc 2.17 以前では、 \fBclock\fP() は \fBtimes\fP(2) を使って実装されていた。 glibc 2.18 以降では、 精度を向上させるため、 \fBclock_gettime\fP(2) (の \fBCLOCK_PROCESS_CPUTIME_ID\fP クロック) を使って実装されている。 .SH 関連項目 \fBclock_gettime\fP(2), \fBgetrusage\fP(2), \fBtimes\fP(2) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.65 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。