#include <sys/time.h> long gettime() { timeval t; gettimeofday(&t, NULL); return 1000*t.tv_sec + t.tv_usec/1000; }