Changed gettimeofday unix function for win32 to use a higher resolution timer.
This commit is contained in:
@@ -51,8 +51,28 @@ static uint32_t Timer_Period = 1;
|
|||||||
* Description: simulate the gettimeofday Linux function
|
* Description: simulate the gettimeofday Linux function
|
||||||
* Returns: zero
|
* Returns: zero
|
||||||
* Note: The resolution of GetSystemTimeAsFileTime() is 15625 microseconds
|
* Note: The resolution of GetSystemTimeAsFileTime() is 15625 microseconds
|
||||||
|
* The resolution of _ftime() is 16 milliseconds
|
||||||
|
* The only way to get microseconds accuracy is to use QueryPerformanceCounter
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
#if 1
|
#if 1
|
||||||
|
int gettimeofday(
|
||||||
|
struct timeval *tp,
|
||||||
|
void *tzp)
|
||||||
|
{
|
||||||
|
/* QPC uses frequency and ticks */
|
||||||
|
LARGE_INTEGER tickPerSecond;
|
||||||
|
LARGE_INTEGER tick;
|
||||||
|
time_t rawtime;
|
||||||
|
|
||||||
|
time(&rawtime);
|
||||||
|
QueryPerformanceFrequency(&tickPerSecond);
|
||||||
|
QueryPerformanceCounter(&tick);
|
||||||
|
tv->tv_usec = (tick.QuadPart % tickPerSecond.QuadPart);
|
||||||
|
tp->tv_sec = (long)rawtime;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#elif 0
|
||||||
int gettimeofday(
|
int gettimeofday(
|
||||||
struct timeval *tp,
|
struct timeval *tp,
|
||||||
void *tzp)
|
void *tzp)
|
||||||
|
|||||||
Reference in New Issue
Block a user