Forms Delphi

Title: measure an elapsed time with a high-resolution performance counter?
{
You want to measure the elapsed time in a repeat, while or a for -Loop
to do some optimation ?
Sie möchten eine Routine mit einer repeat, while oder for i :=...hinsichtlich der
durchlaufenen Zeit messen, um z.B.Optimierungsaktivitäten durchzuführen.
}
// Global Variables, Globale Variablen:
t1, t2, Res: TLargeInteger;
bOk: BOOL;
implementation
uses Windows, dialogs;
procedure StartTimer;
begin
bOK := QueryPerformanceFrequency(Res);
if bOK then
QueryPerformanceCounter(t1);
end;
procedure StopTimer;
begin
if bOK then
QueryPerformanceCounter(t2);
end;
procedure LoopRoutine;
var
iCounter: integer;
begin
StartTimer;
// Put here some kind of loop: For, While or Repeat
for i := 0 to iCounter do...
{ WHILE....
repeat...until}
{ After the Loop/
Nach Abschluss der Schleifenroutine:}
if bOK then
QueryPerformanceCounter(t2);
end;
procedure StartSchleife;
begin
LoopRoutine;
if bOK then
{$IFDEF VER80}
// Show the elapsed time:
MessageDlg('Der Schleifendurchlauf dauerte: ' + Format('%g Sekunden.',
[(t2.QuadPart - t1.Quadpart) / Res.QuadPart]));
$Else {$IFDEF VER120}
MessageDlg('Der Schleifendurchlauf dauerte: ' + Format('%g Sekunden.',
[(t2 - t1) / Res]));
{$ENDIF}
end;