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 - CPU time used since the program call

&pagelevel(4)&pagelevel

Definition

#include <time.h>

clock_t clock(void);

clock supplies the CPU time which has elapsed since the program was called.

Return val.

The CPU time in ten thousandths of a second since the program was called

if successful.

(clock_t) -1 if the time cannot be calculated or represented.

Notes

clock is implemented as a macro and as a function (see section “Functions and macros”).

To obtain the time in seconds, the result of clock must be divided by the value of the
CLOCKS_PER_SEC macro.

Example

#include <time.h>

#include <stdio.h>

int main(void)

{

  clock_t result;

  result = clock();

  printf("used cputime %f seconds\n", ((float)result / CLOCKS_PER_SEC));

  return 0;

}

See also

cputime