[fpc-pascal] Very vague gettickcount64 description?
Yuriy Sydorov
jura at cp-lab.com
Sun Sep 8 13:17:18 CEST 2019
On 08.09.2019 13:42, Michael Van Canneyt wrote:
>
> On Sun, 8 Sep 2019, Yuriy Sydorov wrote:
>>
>> Strictly defined measurement units are important for cross-platform (and Delphi) compatibility. So GetTickCount_2 -
>> GetTickCount_1 must return how many milliseconds have elapsed between calls of GetTickCount regardless of the platform
>> where the program is running.
>
> I understand, but I remain with my point of view that this is a worthless measurement
> if you simply do gettick; operation; gettick;
>
> Since gettick itself takes time (definitely the fallback to fpgettimeofday) the measurement itself influences the
> resulting time (a bit like quantum theory).
> So for small times, I would distrust anything measured like that.
>
> For good measurements, you need to repeat the operation say 100x or 1000x and average out. And then you can just use now().
Sure, measurements using GetTickCount is not precise (+-20ms on Windows). Back in old days using GetTickCount was much
faster than using Now which involves floating point operations. So when checking various timeouts in loops GetTickCount
was preferable than Now. I have lot of old code which uses GetTickCount. Even in my current code I prefer GetTickCount
for calculating small timeouts:
if GetTickCount - FStartTime > 3000 then ;
vs
if Now - FStartTime > 3/SecsPerDay then ;
Yuriy.
More information about the fpc-pascal
mailing list