difftime
Calculates the difference between two calendar times (function or macro)
#include <time.h> double difftime ( time_t time1, time_t time0);
difftime returns the difference between the two times in seconds as a double type.
The difftime function or macro calculates the difference between time1 and time0 ( time1 - time0).
asctime, asctime_r, clock, ctime, ctime_r, gmtime, gmtime_r, localtime, localtime_r, mktime, strftime, time
#include <stdio.h> #include <time.h> void time_test () { extern compute (); time_t start_time, end_time; start_time = time (NULL); compute(); end_time = time (0); printf("Elapsed time: %u seconds", (unsigned int) difftime(end_time, start_time)); }
produces the following:
Elapsed time: 14 seconds