Indy 9 | Content | Index | Reference

GetTickDiff
See Also, Unit: IdGlobal
Calculates the elapsed tick count from two tick count values.

    function GetTickDiff(const AOldTickCount: Cardinal; const ANewTickCount: Cardinal): Cardinal;

Unit
IdGlobal
Parameters
const AOldTickCount: Cardinal
Starting tick count
const ANewTickCount: Cardinal
Ending tick count
Description
GetTickDiff is a Cardinal function that calculates the elapsed tick count using the values in AOldTickCount and ANewTickCount. AOldTickCount and ANewTickCount are the starting and ending tick counts as returned by the GetTickCount function. GetTickDiff exists because a GetTickCount value can rollover to zero (0) when it exceeds the maximum value represented in the Cardinal data type.

GetTickDiff handles this situation in calculating the elapsed tick count. When ANewTickCount is greater than (or equal to) AOldTickCount, the return value is calculated using:

        ANewTickCount - AOldTickCount;

When ANewTickCount is less than AOldTickCount, the return value is adjusted and calculated using:

        High(Cardinal) - AOldTickCount + ANewTickCount;

GetTickDiff is used when calculating the values returned in TIdEcho.EchoTime and TIdEchoUDP.EchoTime, as well as the values returned in TIdTime.RoundTripDelay and TIdTimeUDP.RoundTripDelay.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.