Measuring Time Complexity
Measuring Time Complexity
Used to store the processor time interms of the number of CPU cycles
passes since the start of the process.
clock ()
time.h
Return Type
Example
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main(){
clock_t start, end, duration;
start = clock();
for(int i=0; i<60; i++){
log(100);
}
end = clock();
duration = (end - start);
printf("Processor cycles taken : %f cycles\n", (float)duration);
printf("Processor time taken : %f seconds\n",
(float)duration/CLOCKS_PER_SEC);
getch();
return 0;
}