Name
clock function — Gets the processor time
Synopsis
clock_t clock( )
The clock
function returns
the amount of processor time used since an implementation-defined
start time. The time is returned in implementation-defined units.
There are CLOCKS_PER_SEC
units
per second.
The value returned by the clock
function is not useful by itself but
is intended to be used by comparing it with the value returned from
an earlier call to clock
. For
example, the first statement in the main
function might be a call to clock
; the difference between subsequent
calls and the original call tell you how much time has elapsed since
the program started.
If the environment cannot provide the processor time, static_cast<clock_t>(-1)
is
returned.
See Also
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.