Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

clock - report CPU time used by a process

&pagelevel(4)&pagelevel

Syntax

#include <time.h>

clock_t clock(void);

Description

The behavior of clock() is determined by the selected functionality (see "Selecting functionality") as described below:

When called with POSIX functionality, clock() returns the elapsed CPU time since the first clock call.

BS2000
When called with BS2000 functionality, clock() returns the CPU time since the start of the
program. (End)

Return val.

Amount of CPU time elapsed since the first call to clock()

if successful. The return value for the first call to clock() is 0.

BS2000
CPU time since the start of the program


if successful. (End)

(clock_t)-1

if the CPU time is not available or cannot be represented. This applies to
both POSIX and BS2000 functionality.

Notes

The value returned by clock() is defined in ten thousandths of a second for compatibility
across systems that have CPU clocks with high resolutions. Consequently, the value
returned by clock() may wrap around to 0 on some systems. For example, on a machine
with 32-bit values for clock_t, it will wrap after 2147 seconds or 36 minutes.

If the CPU time is to be specified in seconds, the return value of clock() must be divided
by the value of the macro CLOCKS_PER_SEC (see time.h).

See also

asctime(), cputime(), ctime(), difftime(), gmtime(), localtime(), mktime(),
strftime(), strptime(), system(), time(), times(), utime(), wait(), time.h,
"Selecting functionality".