Fast timer, NOT win32

Started by
10 comments, last by dusik 22 years, 2 months ago
If it's for PC (wellpost pentium) then can't you just use the RDTSC - read time stamp counter. Something similar must exist on the Mac,etc so you could wrap in it in a function pointer or #define.

It'll give you accuracy to the hertz (as in megahertz).


There's Intel link here:
http://cedar.intel.com/cgi-bin/ids.dll/content/content.jsp?cntKey=Legacy::irtp_RDTSCPM1_12033&cntType=IDS_EDITORIAL
Or just search for RDTSC on google

Edited by - chrisflatley on February 17, 2002 6:43:18 PM
Advertisement
  __int64 __declspec(naked) __fastcall RDTSC()	{	_asm		{		cpuid		rdtsc		ret		}	}  


Declare the __int64''s you stuff the result into as volatile __int64.


Problem is you need to first time the CPU using one of the timing function in order to determine the clock MHz - which is needed to measure time with rdtsc. (You need the processor pack for MSVC6 for this to compile).

Magmai Kai Holmlor

"Oh, like you''ve never written buggy code" - Lee
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement