Timing¶
Timing¶
Sleep¶
procedure Sleep(MilliSeconds: UInt32);
PreciseSleep¶
procedure PreciseSleep(Milliseconds: UInt32);
Much more accurate sleep method, if you need millisecond accurate sleeps under -50ms use this.
Note
This is only useful on Windows since on Linux and MacOS the regular Sleep
is accurate to the milliseconds.
MillisecondsToTime¶
function MillisecondsToTime(Time: UInt64; out Days, Hours, Mins, Secs: Integer): Integer;
Converts time (in milliseconds) to days,hours,mins and seconds. Any remaining milliseconds are returned in the Result.¶
MillisecondsToTime¶
function MillisecondsToTime(Time: UInt64; out Years, Months, Weeks, Days, Hours, Mins, Secs: Integer): Integer;
Converts time (in milliseconds) to years,months,weeks,days,hours,mins and seconds. Any remaining milliseconds are returned in the Result.¶
PerformanceTimer¶
function PerformanceTimer: Double;
FormatMilliseconds¶
function FormatMilliseconds(Time: Double; Format: String): String;
Formats milliseconds into a string. Formatting is defined by the Format
string.
WriteLn FormatMilliseconds(GetTickCount(), 's\s\e\c, m\m\i\n');
WriteLn FormatMilliseconds(GetTickCount(), 'hh\h:mm\m:ss\s:uu\m\s');
WriteLn FormatMilliseconds(GetTickCount(), 'YY-MM-DD h:m:s:u');
FormatMilliseconds¶
function FormatMilliseconds(Time: Double; TimeSymbols: Boolean = False): String;
GetTimeRunning¶
function GetTimeRunning: UInt64;
Returns the current script runtime in milliseconds.¶
GetTickCount¶
function GetTickCount: UInt64;
Returns the number of milliseconds that have elapsed since the system was started. However the more important use case of this function is for measuring time:
T := GetTickCount();
Sleep(1000);
WriteLn('Should be around ~1000 :: ', GetTickCount()-T);
Resolution is typically in the range of 10 milliseconds to 16 milliseconds.
If you need a more accurate timer use PerformanceTimer