#include <stdio.h>
#include <sys/time.h>
/*
struct timeval {
long tv_sec; // seconds
long tv_usec; // microseconds
};
*/
int main() {
struct timeval timevalBefore, timevalAfter;
gettimeofday(&timevalBefore, NULL);
for (int i = 0; i < 10000000; i++) ;
gettimeofday(&timevalAfter, NULL);
printf("%ld microseconds\n", timevalAfter.tv_usec - timevalBefore.tv_usec);
return 0;
}
/*
run:
19592 microseconds
*/