C Programming Language |
malloc |
calloc |
memset |
memcpy |
memory |
strcpy |
string |
strtok |
isalnum |
cctype |
errno |
cfenv |
clock |
difftime |
mktime |
ctime |
fprintf |
fscanf |
printf |
scanf |
stdio |
math |
time.h
clock_t clock(void);
The clock() function returns an approximation of processor time used by the program.
Note that the time can wrap around. On a 32-bit system where CLOCKS_PER_SEC equals 1000000 this function will return the same value approximately every 72 minutes.
returns approximate processor time that is consumed by the program since launched, and on failure returns -1.
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
// gcc -o clock_prg clock_prg.c
// ./clock_prg
int main ()
{
clock_t clock_start_time;
clock_t clock_end_time;
clock_t clock_taken_time;
clock_start_time = clock();
printf("clock_start_time = %ld\n", clock_start_time);
int r = 0;
int zz = 0;
while( zz < 999999)
{
r = rand();
zz++;
}
clock_end_time = clock();
clock_taken_time = (double)(clock_end_time - clock_start_time) / CLOCKS_PER_SEC;
printf("clock_end_time = %ld, application taken processor time: %f\n", clock_end_time, clock_taken_time);
return EXIT_SUCCESS;
}
clock_start_time = 0
clock_end_time = 20000, application taken processor time: 0.000000
zalloc is a third party library
posted on 2018-12-12 20:46:30 - C Programming Language Tutorials
posted on 2017-12-29 22:52:47 - C Programming Language Tutorials