Code archives/Miscellaneous/High Resolution Timer Module
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This is some timer code I wrote a while ago using high resolution timers. It will only work on windows machines. The mod isn't complete, I wrote it for my own purposes and put in the functionality I needed. Feel free to expand on it. Place this code in blitzmax/mod/toad.mod/counter.mod Use it in your program by putting Import toad.counter at the top. GetTicks() returns the number of ticks since the program started. GetMillisecs() returns the number of milliseconds since program start. The value returned is double precision. | |||||
Module toad.counter Extern "Win32" Function QueryPerformanceCounter(lpPerformanceCount:Long Var) Function QueryPerformanceFrequency(lpFrequency:Long Var) End Extern Function GetTicks:Long() Local Ticks:Long If QueryPerformanceCounter(Ticks) Return Ticks Else Return 0 End If End Function Function GetMillisecs:Double() Global Firstcall:Int = True Global Frequency:Long Local Ticks:Long If Firstcall QueryPerformanceFrequency(Frequency) Firstcall = False End If If QueryPerformanceCounter(Ticks) Return (Double(Ticks * 1000) / Frequency) Else Return 0 End If End Function |
Comments
| ||
hehe cool. There are a few of these around (coded one meself too- also in the archives.) Cool that you made it a module. |
Code Archives Forum