#include /* function to get time in seconds since "epoch" */ /* uses Linux library function gettimeofday, so may not be portable */ double get_time() { struct timeval tv; struct timezone tz; if (gettimeofday(&tv, &tz) == 0) return ((double) (tv.tv_sec * 1000 + (tv.tv_usec + 500) / 1000))/1000.0; else return 0.0; }