clock

De RAD Studio
Aller à : navigation, rechercher

Remonter à time.h - Index


Header File

time.h

Category

Time and Date Routines

Prototype

clock_t clock(void);

Description

Determines processor time.

clock can be used to determine the time interval between two events. To determine the time in seconds, the value returned by clock should be divided by the value of the macro CLK_TCK.

Return Value

On success, clock returns the processor time elapsed since the beginning of the program invocation.

On error (if the processor time is not available or its value cannot be represented), clock returns -1.

Example

#include <time.h>
#include <stdio.h>
#include <windows.h>
int main(void)
{
   clock_t start, end;
   start = clock();
   Sleep(2000);
   end = clock();
   printf("The time was: %f\n", (end - start) / CLK_TCK);
   return 0;
}

Portability

POSIX Win32 ANSI C ANSI C++

+

+

+

+