$IFNDEF __WIN32API
$IFNDEF __RQINC2
TYPE LARGE_INTEGER
LowPart AS LONG
HighPart AS LONG
END TYPE
$ENDIF
DECLARE FUNCTION QueryPerformanceCounter LIB "kernel32" Alias_
"QueryPerformanceCounter" (lpPerformanceCount AS LONG) AS LONG
DECLARE FUNCTION QueryPerformanceFrequency LIB "kernel32" Alias_
"QueryPerformanceFrequency" (lpFrequency AS LONG) AS LONG
$ENDIF
FUNCTION MicroTimer_dwToDbl (iDw AS LONG) AS DOUBLE
DEFDBL dwTmp, dbl2exp31
dwTmp = iDw
dbl2exp31 = 2147483648
IF dwTmp < 0 THEN
dwTmp = dwTmp SHL 1
dwTmp = dwTmp SHR 1
Result = dbl2exp31 + dwTmp
ELSE
Result = dwTmp
END IF
END FUNCTION
FUNCTION microTIMER() AS DOUBLE
STATIC AlreadyInit AS INTEGER
STATIC myFreq AS DOUBLE
DIM TimerFreq AS LARGE_INTEGER
DIM TimerMS AS LARGE_INTEGER
DIM myResult AS DOUBLE
IF AlreadyInit = 0 THEN
QueryPerformanceFrequency(TimerFreq)
AlreadyInit = 1
IF TimerFreq.HighPart = 0 THEN
myFreq = MicroTimer_dwToDbl(TimerFreq.LowPart)
ELSE
RESULT = 0.0
EXIT FUNCTION
END IF
END IF
QueryPerformanceCounter(TimerMS)
myResult = MicroTimer_dwToDbl(TimerMS.HighPart) * 4294967296.0_
+ MicroTimer_dwToDbl(TimerMS.LowPart)
RESULT = myResult / myFreq
END FUNCTION
|