Wednesday, March 10, 2010

Some issues in C runtime calculation

use time.h

The clock() function has limitation in terms of the maximum value returned
on a 32 bit machine it overflows at around 36 minutes

use time() function instead.

Time returns no of seconds since epoch.
time_t start, end;
time(&start);
/*Do Something*/
time(&end);
printf("Runtime in seconds %d\n", (int)end-start);


No comments: