z4none
6/11/2019 - 2:41 PM

Get the current time in microseconds in C.

Get the current time in microseconds in C.

#include <sys/time.h>

/**
 * Returns the current time in microseconds.
 */
long getMicrotime(){
	struct timeval currentTime;
	gettimeofday(&currentTime, NULL);
	return currentTime.tv_sec * (int)1e6 + currentTime.tv_usec;
}