Skip to content

Commit

Permalink
Added Profiler.Trace to profile Proc() and Profiler-Trae<T> to profil…
Browse files Browse the repository at this point in the history
…e Func<T>
  • Loading branch information
danieleteti committed Jul 25, 2024
1 parent 4371653 commit 63ae0d6
Show file tree
Hide file tree
Showing 4 changed files with 398 additions and 185 deletions.
13 changes: 11 additions & 2 deletions samples/profiling_showcase/MainFormU.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ object MainForm: TMainForm
Left = 0
Top = 0
Caption = 'Profiler :: Sample'
ClientHeight = 232
ClientHeight = 302
ClientWidth = 560
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Expand All @@ -13,7 +13,7 @@ object MainForm: TMainForm
OnCreate = FormCreate
DesignSize = (
560
232)
302)
TextHeight = 15
object btnSimple: TButton
Left = 16
Expand Down Expand Up @@ -52,4 +52,13 @@ object MainForm: TMainForm
TabOrder = 3
OnClick = chkLogsThresholdClick
end
object btnTrace: TButton
Left = 16
Top = 240
Width = 129
Height = 41
Caption = 'Trace'
TabOrder = 4
OnClick = btnTraceClick
end
end
24 changes: 24 additions & 0 deletions samples/profiling_showcase/MainFormU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ TMainForm = class(TForm)
btnNestedCalls: TButton;
btnNestedCallsInLoop: TButton;
chkLogsThreshold: TCheckBox;
btnTrace: TButton;
procedure btnSimpleClick(Sender: TObject);
procedure btnNestedCallsClick(Sender: TObject);
procedure btnNestedCallsInLoopClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure chkLogsThresholdClick(Sender: TObject);
procedure btnTraceClick(Sender: TObject);
private
{ Private declarations }
public
Expand Down Expand Up @@ -70,6 +72,28 @@ procedure TMainForm.btnSimpleClick(Sender: TObject);
DoSomething;
end;

procedure TMainForm.btnTraceClick(Sender: TObject);
begin
Profiler.Trace('Test PROC',
procedure
begin
Sleep(Random(20));
end, 10);


var lRes := Profiler.Trace<String>('Test FUNC',
function: String
var
I: Integer;
begin
for I := 1 to 10 do
begin
Result := Result + 'x';
Sleep(Random(5));
end;
end, 10);
end;

procedure TMainForm.chkLogsThresholdClick(Sender: TObject);
begin
Profiler.LogsOnlyIfOverThreshold := chkLogsThreshold.Checked;
Expand Down
Loading

0 comments on commit 63ae0d6

Please sign in to comment.