how microseconds timestamp in c?
i'm trying do:
struct timeval tv; gettimeofday(&tv,null); return tv.tv_usec;
but returns nonsense value if 2 timestamps, second 1 can smaller or bigger first (second 1 should always bigger). possible convert magic integer returned gettimeofday normal number can worked with?
you need add in seconds, too:
unsigned long time_in_micros = 1000000 * tv.tv_sec + tv.tv_usec;
note last 232/106 =~ 4295 seconds, or 71 minutes though (on typical 32-bit system).
Comments
Post a Comment