John,

If you are using a Pentium, there is an instruction that reads a 64 bit 
counter. Try the following:

|*function* RDTSC: Int64; *assembler*;
*asm*
  RDTSC  /// result Int64 in EAX and EDX/
*end*;

The value returned is the number of clock cycles since reboot. If the 
compiler you are using converts this to inline code, then the only 
overhead is the instruction itself. Don't know the performance, but in 
Delphi 6 & 7, it was about 84 clock cycles. Delphi 2005, 2006 should be 
much less.

Note that you need to know the machine's CPU clock rate to convert this 
to a time. If you are trying to time code, then this isn't important, 
just count the clock cycles.

Have a look at this web site for more info on how to implement in 
different versions of Delphi:

http://www.geocities.com/izenkov/howto-rdtsc.htm

Peter
|
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to