Created
July 13, 2012 03:29
-
-
Save zhoukuo/3102530 to your computer and use it in GitHub Desktop.
Calculate the execution time of second
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* use time() to calculate the execution time in second */ | |
#include <time.h> | |
long timecost(void (*dosomething)()) | |
{ | |
time_t start, end; | |
long cost; | |
start = time(NULL); | |
dosomething(); | |
end = time(NULL); | |
cost = (int)difftime(end, start); | |
printf("cost time: %ld seconds", cost); | |
return cost; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment