Wednesday, October 16, 2013

Measuring code performance in Delphi Scripts

First step in code optimization is to determine which procedures in our code need to be optimized.

A millisecond timer is needed to test for the elapsed time required to execute the code.

On a Windows Machine we can use 'GetTickCount'.  Below is a code snippet for Delphi.

procedure TForm1.ButtonClick(Sender: TObject);
var
  startTick  : DWord;
  delta      : DWord;
begin
  startTick := GetTickCount;

  DoSomething; // Your Code

  delta := GetTickCount - startTick;
  ShowMessage(IntToStr(delta) + 'ms');
end;


See what CapnBry has to say about GetTickCount:

'via Blog this'

No comments:

Post a Comment