[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

clock Subroutine

Purpose

Reports central processing unit (CPU) time used.

Library

Standard C Library (libc.a)

Syntax

#include <time.h>
clock_t clock (void);

Description

The clock subroutine reports the amount of CPU time used. The reported time is the sum of the CPU time of the calling process and its terminated child processes for which it has executed wait, system, or pclose subroutines. To measure the amount of time used by a program, the clock subroutine should be called at the beginning of the program, and that return value should be subtracted from the return value of subsequent calls to the clock subroutine. To find the time in seconds, divide the value returned by the clock subroutine by the value of the macro CLOCKS_PER_SEC, which is defined in the time.h file.

Return Values

The clock subroutine returns the amount of CPU time used.

Implementation Specifics

This subroutine is part of Base Operating System (BOS) Runtime.

Related Information

The getrusage, times subroutine, pclose subroutine, system subroutine, vtimes subroutine, wait, waitpid, wait3 subroutine.

Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]