On Tue, 22 Feb 2011, Bo Berglund wrote:

On Tue, 22 Feb 2011 08:50:33 +0100 (CET), Michael Van Canneyt
<[email protected]> wrote:

I should have added that instead of a sawtooth like noise component
using Frac(Now()) * 24*3600 to get the second since midnight gives
random noise in the seconds values of about 3-4 ms.
Another observation is that there seems to be no data smaller than ms.
If I format this value as a float with more decimals than 3 I always
only see zeroes.

That is logical, since TDateTime only is accurate to millisecond precision.


Granted that, but right now I am mostly interested in finding a way to
time an external event source such that I can measure the time between
events.

After googling a bit I have come up with the following, which is a
variation of a delay function that I created years ago in Delphi to
enable me to output pulses that are timed to milliseconds.
The delay is now converted to a time retrieval function:

function TForm1.GetMillisecondTime: Int64;
var
 Freq,
 Ts: Int64;
begin
 QueryPerformanceCounter(Ts);
 QueryPerformanceFrequency(Freq);
 if (Ts = 0) or (Freq = 0) then exit;
 Freq := Freq div 1000;
 Result := TS div Freq;
end;

When I try this in Lazarus I get an "Identifier not found" error (not
surprising).
What should I do in order to get this to compile?
Any suitable unit to add to the uses clause?

If you are on windows: add the windows unit.

If you are on another platform: these functions simply do not exist on other 
platforms.

Michael.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to