{
A high-precision counter/timer. Retrieves time differences
downto microsec.
Quick Reference:
THPCounter inherits from TComponent.
Key-Methods:
Start: Starts the counter. Place this call just before the
code you want to measure.
Read: Reads the counter as a string. Place this call just
after the code you want to measure.
ReadInt: Reads the counter as an Int64. Place this call just
after the code you want to measure.
--------------------------------------------------------------------------------
}
unit HPCounter;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text:= '';
Application.ProcessMessages;
with THPCounter.Create(Self) do
begin
Start;
// Place code to measure here
Sleep(1000);
// Place code to measure here
Edit1.Text:=Read;
Free;
end;
end;
procedure Delay(MSecs : Longint);
var
FirstTickCount, Now : Longint;
begin
FirstTickCount := GetTickCount;
repeat
Application.ProcessMessages;
Now := GetTickCount;
until (Now - FirstTickCount >= MSecs) or (Now < FirstTickCount);
end;