#include <stdio.h> #include <time.h> #include <sys/time.h> int main(void) { struct timeval begin, end; struct timezone tz; int i = 0; long time = 0; gettimeofday(&begin, &tz); /* Operation */ for (i = 0; i < 100000; ++i) ; gettimeofday(&end, &tz); time = (end.tv_sec - begin.tv_sec) * 1000000L + (end.tv_usec - begin.tv_usec); printf("%ld us\n", time); return 0; }
gcc -W -Wall -pedantic time.c
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question