High Precision Timers

Started by
10 comments, last by Jan Wassenberg 18 years, 7 months ago
Here's part of my timer class. I don't remember exactly where I got the ASM, but it seems to work pretty well:

void P25DTIMER::GetTick(void* Tick){    if(m_TimerType == P25DTMR_CPU)    {        __asm        {	    PUSH  EDX;	    PUSH  ECX;	    MOV   ECX, Tick;	    _EMIT 0Fh	    _EMIT 31h	    MOV   [ECX], EAX;	    MOV   [ECX + 4], EDX;	    POP	 ECX;	    POP   EDX;	}    }    else if(m_TimerType == P25DTMR_HIRES)    {	QueryPerformanceCounter((LARGE_INTEGER*)Tick);    }}


Then you can use it like:
float CurrentTick = 0.0f;
GetTick(&CurrentTick);
Advertisement
Due to lack of time all I can do is upload the wtime source/header to look at (GPL license); as said, the dependencies (system detect, CPU) are scattered around and cannot easily be included.
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3

This topic is closed to new replies.

Advertisement