clock(S-osr5)
clock --
report CPU time used
Syntax
cc . . . -lc
long clock ()
Description
The clock function
returns the amount of CPU time (in microseconds)
used since the first call to clock.
The time reported is the sum of the user and system times of the
calling process and its terminated child processes for which it has executed
wait(S-osr5),
pclose(S-osr5),
or
system(S-osr5).
The resolution of the time values returned is 10,000 microseconds
(10 milliseconds),
corresponding to the value of HZ within the kernel..
Notes
The value returned
wraps around after accumulating
2147 seconds of CPU time (about 36 minutes).
Code that compares old and new clock values
must be written to be accurate across these wraps.
For example, to determine
whether or not MAX_TIME has passed
since start_time:
int start_time
if (clock - start_time >= MAX_TIME)
This subtraction works whether
clock( )
values are negative or positive.
start_time must be declared
as a signed integer.
Avoid using constructions such as the following:
if (clock >= (start_time + MAX_TIME)) /* INCORRECT use of clock */
This fails if (start_time + MAX_TIME) is positive
while
clock( )
has wrapped and is negative.
See also
clock(HW),
popen(S-osr5),
system(S-osr5),
times(S-osr5),
wait(S-osr5)
Standards conformance
clock is conformant with:
X/Open Portability Guide, Issue 3, 1989
.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005