[Lazarus] TTimer simple issue
bo.berglund at gmail.com
Tue Oct 27 15:21:12 CET 2020
On Tue, 27 Oct 2020 14:40:27 +0100, Darius Blaszyk via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
>>> But this is very not a very efficient way. The best is to get the start
>>> time, get the end time and subtract.
>>> i, answer: integer;
>>> for i := 0 to 999999999 do
>>> answer := i * answer;
>>> memo1.lines.add('time spent: ' + TimeToStr(EndTime-StarTime) );
>>> But TDateTime is not accurate at all if you are measuring short periods
i, answer: integer;
answer := 1;
StartTime := GetTickCount64;
for i := 0 to 999999999 do
answer := i * answer; //What does this really do?
EndTime := GetTickCount64;
memo1.lines.add('ms spent: ' + IntToStr(EndTime-StartTime));
Now() is an extremely bad time source since it is really only fairly
accurate to seconds. It also uses floating point so it is rounding.
Int64 holds the same bumber of bits as a double but all of it is
dedicated to the number.
Developer in Sweden
More information about the lazarus