[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, 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.

Related Information

The getrusage, times (getrusage, getrusage64, times, or vtimes Subroutine) subroutine, pclose (pclose Subroutine) subroutine, system subroutine, vtimes (getrusage, getrusage64, times, or vtimes Subroutine) subroutine, wait, waitpid, wait3 subroutine.

Subroutines Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]