<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 26, 2016 at 11:21 AM, Dmitry Boyarintsev <span dir="ltr"><<a target="_blank" href="mailto:skalogryz.lists@gmail.com">skalogryz.lists@gmail.com</a>></span> wrote:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div dir="ltr"><div class="gmail_extra">Maybe you want to look into QueryPerformanceCounter.<br><a target="_blank" href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904%28v=vs.85%29.aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx</a><br><br></div></div></blockquote><div>Here's an example:<br><br>{$mode objfpc}{$H+}<br><br>uses<br>  Windows;<br><br>const<br>  MSInSec = 1000;<br>  MCInSec = MSInSec * 1000;<br>  NSInSec = MCInSec * 1000;<br><br>function LargeLoop: Integer;<br>var<br>  i : integer;<br>begin<br>  Result:=0;<br>  for i:=0 to 1000 do<br>    inc(Result);<br>   //or you can verify Sleep(milliseconds)<br>   //Sleep(100);<br>end;<br><br>var<br>  fr : TLargeInteger;<br>  ct : TLargeInteger;<br>  af : TLargeInteger;<br>  d  : double;<br>  diff : TLargeInteger;<br>begin<br>  QueryPerformanceFrequency(fr);<br>  writeln('Frequency: ' ,fr);<br>  d:=(1/fr) * NSInSec;<br>  writeln('Freq in Time: ', d:0:0, ' ns (roughly)');<br>  QueryPerformanceCounter(ct);<br>  LargeLoop;<br>  QueryPerformanceCounter(af);<br>  diff := af - ct;<br>  writeln('Loop:');<br>  writeln('  Ticks: ', diff);<br>  writeln('  Time:  ', ((diff/fr) * NSInSec):0:0,' ns' );<br>  writeln('         ', ((diff/fr) * MCInSec):0:6,' mcs' );<br>  writeln('         ', ((diff/fr) * MSInSec):0:6,' ms' );<br>end.<br><br> <br></div></div><br></div></div>