Strict
Extern "win32"
Function QueryPerformanceFrequency(LARGE_INTEGER:Long Var)
Function QueryPerformanceCounter(LARGE_INTEGER:Long Var)
EndExtern
' ----------------------------------------------------------------------------------------------
Global ProfileTimer:TPerformanceTime = New TPerformanceTime
Tperformancetime.SetResolution(6) '6 digits
ProfileTimer.Start()
Delay 1001
del= ProfileTimer.Stop() ' should print 1 (or so)
Print del
End
Graphics 640,480,32,85
' ----------------------------------------------------------------------------------------------
Type TPerformanceTime
Global Frequency:Long
Field StartTime:Long
Field StopTime:Long
Function SetResolution(Digits:Int)
QueryPerformanceFrequency(Frequency)
frequency=frequency/(10^digits)
End Function
Method New()
If Not Frequency Then QueryPerformanceFrequency(Frequency)
EndMethod
' returns the current system time
Method Time:Double()
Local Time:Long
QueryPerformanceCounter(Time)
Return Double(Time)/Frequency
EndMethod
' start the stopwatch
Method Start()
QueryPerformanceCounter(StartTime)
EndMethod
' will return the stopwatch result, can be called more than once!
Method Stop:Double()
QueryPerformanceCounter(StopTime)
Return Double(StopTime-StartTime)/Frequency
EndMethod
EndType