Timing¶
Timing in milliseconds
var
t: Int64;
begin
t := Time();
for 1 to 10 do
Sleep(100);
WriteLn('Took: ', Time()-t, ' ms');
// 1 hour, 2.5 sec in milliseconds
t := 60*60000+2500;
WriteLn FormatMilliseconds(t, 'hh:mm:ss:uu');
end;
Time¶
function Time: Int64;
Return a timestamp for measuring time.
Note
The timestamp returned is unix time in milliseconds. Divide by 1000 to get seconds.
PerformanceTime¶
function PerformanceTime: Double;
Return a high resolution timestamp. Use this for accurately measuring very short time intervals.
Sleep¶
procedure Sleep(Milliseconds: UInt32);
PreciseSleep¶
procedure PreciseSleep(Milliseconds: UInt32);
High resolution sleep, like PerformanceTime
use this when needing to sleep very short time intervals accurately.
MillisecondsToTime¶
function MillisecondsToTime(Time: Int64; out Days, Hours, Mins, Secs: Integer): Integer;
MillisecondsToTime¶
function MillisecondsToTime(Time: Int64; out Years, Months, Weeks, Days, Hours, Mins, Secs: Integer): Integer;
FormatMilliseconds¶
function FormatMilliseconds(Time: Int64; Format: String): String;
Y = years
M = months
W = weeks
D = days
h = hours
m = minutes
s = seconds
u = milliseconds
Note
Doubling an argument will add padding. Example hh
will produce 01
\
will escape the next character
FormatMilliseconds¶
function FormatMilliseconds(Time: Int64; TimeSymbols: Boolean = False): String;
TStopWatch.StartTime¶
property TStopwatch.StartTime: Int64
Returns the time this stopwatch was started at.
TStopWatch.IsPaused¶
property TStopWatch.IsPaused: Boolean;
TStopWatch.Start¶
procedure TStopWatch.Start;
TStopWatch.Resume¶
procedure TStopWatch.Resume;
TStopWatch.Pause¶
procedure TStopWatch.Pause;
TStopWatch.Reset¶
procedure TStopWatch.Reset;
TStopWatch.Elapsed¶
property TStopwatch.Elapsed: Int64
Returns the milliseconds passed since the stopwatch was started.
TStopWatch.ElapsedFmt¶
function TStopwatch.ElapsedFmt(Format: String = 'u'): String;
TCountDown.StartTime¶
property TCountDown.StartTime: Int64;
Returns the time the countdown was started at.
TCountDown.Start¶
procedure TCountDown.Start(Milliseconds: Int64);
TCountDown.Extend¶
procedure TCountDown.Extend(Milliseconds: Int64);
TCountDown.Remaining¶
property TCountDown.Remaining: Int64;
TCountDown.RemainingFmt¶
function TCountDown.RemainingFmt(Format: String = 'u'): String;
TCountDown.IsFinished¶
property TCountDown.IsFinished: Boolean;
TCountDown.IsPaused¶
property TCountDown.IsPaused: Boolean;
TCountDown.Pause¶
procedure TCountDown.Pause;
TCountDown.Resume¶
procedure TCountDown.Resume;
TCountDown.Restart¶
procedure TCountDown.Restart(Randomness: Integer = 0);