Thanks again everyone for the responses.

Just a bit of background on my application.  I'm running two timers one
every 110 mS to scroll data on a strip chart and one every 1045 mS to get at
least one second worth of data (1045 samples at least).

Turns out some of the time is lost while windows is doing who knows what.
As a result, sometimes the 110 mS timer may not actually run the Timer
method until 140mS has elapsed.  i.e. the windows message for the time-out
is probably put into the message list by the OS but the actual method may
not be run for another 30 mS.  Most of the time it's pretty accurate.

I think my solution is to check how much time in milliseconds has elapsed
since the last 110 mS tick with one of the methods suggested.  Then use that
value as the number of samples to scroll.  That way I shouldn't get behind.

John Dammeyer


> Subject: Re: More accurate timers
> 
> 
> 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
> 
> 

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

Reply via email to