That looks great. I’ll give it a try! Thank you very much for the suggestion and the example
From: [email protected] [mailto:[email protected]] On Behalf Of Dmitry Boyarintsev Sent: Tuesday, July 26, 2016 11:45 AM To: FPC-Pascal users discussions <[email protected]> Subject: Re: [fpc-pascal] Microsecond Delay Suggestions? On Tue, Jul 26, 2016 at 11:21 AM, Dmitry Boyarintsev <[email protected] <mailto:[email protected]> > wrote: Maybe you want to look into QueryPerformanceCounter. https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx <https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904%28v=vs.85%29.aspx> Here's an example: {$mode objfpc}{$H+} uses Windows; const MSInSec = 1000; MCInSec = MSInSec * 1000; NSInSec = MCInSec * 1000; function LargeLoop: Integer; var i : integer; begin Result:=0; for i:=0 to 1000 do inc(Result); //or you can verify Sleep(milliseconds) //Sleep(100); end; var fr : TLargeInteger; ct : TLargeInteger; af : TLargeInteger; d : double; diff : TLargeInteger; begin QueryPerformanceFrequency(fr); writeln('Frequency: ' ,fr); d:=(1/fr) * NSInSec; writeln('Freq in Time: ', d:0:0, ' ns (roughly)'); QueryPerformanceCounter(ct); LargeLoop; QueryPerformanceCounter(af); diff := af - ct; writeln('Loop:'); writeln(' Ticks: ', diff); writeln(' Time: ', ((diff/fr) * NSInSec):0:0,' ns' ); writeln(' ', ((diff/fr) * MCInSec):0:6,' mcs' ); writeln(' ', ((diff/fr) * MSInSec):0:6,' ms' ); end.
_______________________________________________ fpc-pascal maillist - [email protected] http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
