John of Words
0
Q:

measure time in c

clock_t begin = clock();

/* here, do your time-consuming job */

clock_t end = clock();
double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
1
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);
}
1

New to Communities?

Join the community