Using the optional Text parameter

The CodeSiteEx.Timer routine accepts an optional Text parameter.

If you pass a string in this parameter, the method text is evaluated as follows:

    lsMsg := Format('Timed at %s', [TimeString]);
    if FText <> '' then
      lsMsg := FText + ' (' + lsMsg + ')';
    FCS.SendMsg(lsMsg);


Suppose your application has a form with a button, btnOK.  You can profile the button's OnClick event as follows:

  procedure TMyForm.btnOKClick(Sender: TObject);
  begin
    CodeSiteEx.Timer;

    // your code goes here...

  end;

The CodeSite viewer will receive text similar to the following:

  Timed at 1.26 microseconds

But suppose you want more information, such as the name of the method being timed.  You can change the Timer method to include the optional Text parameter, as follows:

  procedure TMyForm.btnOKClick(Sender: TObject);
  begin
    CodeSiteEx.Timer('btnOKClick');

    // your code goes here...

  end;

The CodeSite viewer will now receive text similar to the following:

  btnOKClick (Timed at 1.26 microseconds)