转自:https://gist.github.com/sevko/d23646ba07c77c15fde9
Get the current time in microseconds in C.
程序:
#include <sys/time.h>
/**
* Returns the current time in microseconds.
*/
long getMicrotime(){
struct timeval currentTime;
gettimeofday(¤tTime, NULL);
return currentTime.tv_sec * (int)1e6 + currentTime.tv_usec;
}
运行环境:
linux