#include <sys/time.h>
#define timediff(tv1,tv) (tv1.tv_sec * 1000 * 1000 + tv1.tv_usec - tv.tv_sec * 1000 * 1000 - tv.tv_usec)
timeval tv;
gettimeofday(&tv,NULL);
timeval tv1;
gettimeofday(&tv1,NULL);
double dt = timediff(tv1,tv);
#include <sys/time.h>
#define timediff(tv1,tv) (tv1.tv_sec * 1000 * 1000 + tv1.tv_usec - tv.tv_sec * 1000 * 1000 - tv.tv_usec)
timeval tv;
gettimeofday(&tv,NULL);
timeval tv1;
gettimeofday(&tv1,NULL);
double dt = timediff(tv1,tv);