xxxxxxxxxx
void timeWait (float threshold) {
float timeInitial, timeMeasured, timeDelta = 0;
timeInitial = (float)clock();
while (timeDelta < threshold) {
timeMeasured = (float)clock();
timeDelta = ((timeMeasured - timeInitial) / (float)CLOCKS_PER_SEC);
}
printf("%.2f - %.2f s have passed.", threshold, timeDelta);
}
xxxxxxxxxx
#include <time.h>
clock_t start, end;
double cpu_time_used;
start = clock();
/*
Your Code
*/
end = clock();
cpu_time_used_en = ((double)(end - start));
printf("Time taken: %f\n", cpu_time_used);