| Functions | ||||
| Time manipulation | ||||
(C11) | ||||
(C23) | ||||
| Format conversions | ||||
(deprecated in C23)(C11) | ||||
(deprecated in C23)(C11) | ||||
(C95) | ||||
(C23)(C11) | ||||
(C23)(C11) | ||||
| Constants | ||||
| Types | ||||
clock_t | ||||
(C11) |
Defined in header <time.h> | ||
typedef/* unspecified */ clock_t; | ||
Arithmetic(until C11)Real(since C11) type capable of representing the processor time used by a process. It has implementation-defined range and precision.
#include <stdio.h>#include <time.h>#include <math.h> volatiledouble sink;int main(void){ clock_t start=clock(); for(size_t i=0; i<3141592;++i) sink+=sin(i); clock_t end=clock();double cpu_time_used=((double)(end- start))/CLOCKS_PER_SEC; printf("for loop took %f seconds to execute\n", cpu_time_used);}
Possible output:
for loop took 0.271828 seconds to execute
| returns raw processor clock time since the program is started (function)[edit] | |
| number of processor clock ticks per second (macro constant)[edit] | |
C++ documentation forclock_t | |