Skip to content

Commit

Permalink
Performance counters were added by Ingo for multi-threaded computation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvmorozov committed Nov 28, 2019
1 parent f6eb8b9 commit ef22bbe
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 44 deletions.
86 changes: 43 additions & 43 deletions examples/TBoundingBoxServerForm/bounding_box_server_demo.lps
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="230"/>
<CursorPos X="97" Y="239"/>
<TopLine Value="727"/>
<CursorPos X="19" Y="749"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
Expand Down Expand Up @@ -210,121 +210,121 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="85" Column="41" TopLine="58"/>
<Caret Line="222" Column="14" TopLine="194"/>
</Position1>
<Position2>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="180" Column="14" TopLine="170"/>
</Position2>
<Position3>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="206" Column="14" TopLine="178"/>
<Caret Line="69" Column="18" TopLine="42"/>
</Position3>
<Position4>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="222" Column="14" TopLine="194"/>
<Caret Line="85" Column="41" TopLine="58"/>
</Position4>
<Position5>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="618" Column="69" TopLine="604"/>
</Position5>
<Position6>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="69" Column="18" TopLine="42"/>
<Caret Line="620" Column="35" TopLine="611"/>
</Position6>
<Position7>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="85" Column="41" TopLine="58"/>
<Filename Value="downhill_simplex_handler.pas"/>
<Caret Line="81" Column="20" TopLine="65"/>
</Position7>
<Position8>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="618" Column="69" TopLine="604"/>
<Filename Value="downhill_simplex_handler.pas"/>
<Caret Line="238" Column="40" TopLine="221"/>
</Position8>
<Position9>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="620" Column="35" TopLine="611"/>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="105" Column="31" TopLine="92"/>
</Position9>
<Position10>
<Filename Value="downhill_simplex_handler.pas"/>
<Caret Line="81" Column="20" TopLine="65"/>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="160" Column="39" TopLine="140"/>
</Position10>
<Position11>
<Filename Value="downhill_simplex_handler.pas"/>
<Caret Line="238" Column="40" TopLine="221"/>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="580" Column="8" TopLine="562"/>
</Position11>
<Position12>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="105" Column="31" TopLine="92"/>
<Caret Line="614" Column="36" TopLine="587"/>
</Position12>
<Position13>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="160" Column="39" TopLine="140"/>
</Position13>
<Position14>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="580" Column="8" TopLine="562"/>
<Caret Line="45" Column="62" TopLine="17"/>
</Position14>
<Position15>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="614" Column="36" TopLine="587"/>
<Caret Line="60" Column="17" TopLine="32"/>
</Position15>
<Position16>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="61" Column="17" TopLine="33"/>
</Position16>
<Position17>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="45" Column="62" TopLine="17"/>
<Caret Line="64" Column="20" TopLine="36"/>
</Position17>
<Position18>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="60" Column="17" TopLine="32"/>
<Caret Line="69" Column="22" TopLine="41"/>
</Position18>
<Position19>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="61" Column="17" TopLine="33"/>
<Caret Line="71" Column="22" TopLine="43"/>
</Position19>
<Position20>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="64" Column="20" TopLine="36"/>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="620" Column="35" TopLine="611"/>
</Position20>
<Position21>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="69" Column="22" TopLine="41"/>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="245" TopLine="225"/>
</Position21>
<Position22>
<Filename Value="..\..\package\DownhillSimplexAlgorithm.pas"/>
<Caret Line="71" Column="22" TopLine="43"/>
<Filename Value="..\..\package\RunningThread.pas"/>
<Caret Line="116" TopLine="96"/>
</Position22>
<Position23>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="620" Column="35" TopLine="611"/>
<Filename Value="..\..\package\RunningThread.pas"/>
<Caret Line="117" TopLine="96"/>
</Position23>
<Position24>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="245" TopLine="225"/>
<Filename Value="..\..\package\RunningThread.pas"/>
<Caret Line="118" TopLine="96"/>
</Position24>
<Position25>
<Filename Value="..\..\package\RunningThread.pas"/>
<Caret Line="116" TopLine="96"/>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="245" TopLine="225"/>
</Position25>
<Position26>
<Filename Value="..\..\package\RunningThread.pas"/>
<Caret Line="117" TopLine="96"/>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="239" Column="35" TopLine="232"/>
</Position26>
<Position27>
<Filename Value="..\..\package\RunningThread.pas"/>
<Caret Line="118" TopLine="96"/>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="237" Column="35" TopLine="230"/>
</Position27>
<Position28>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="245" TopLine="225"/>
<Caret Line="241" Column="45" TopLine="230"/>
</Position28>
<Position29>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="239" Column="35" TopLine="232"/>
<Caret Line="747" Column="26" TopLine="730"/>
</Position29>
<Position30>
<Filename Value="bounding_box_server_form.pas"/>
<Caret Line="237" Column="35" TopLine="230"/>
<Caret Line="13" Column="33"/>
</Position30>
</JumpHistory>
</ProjectSession>
Expand Down
15 changes: 14 additions & 1 deletion examples/TBoundingBoxServerForm/bounding_box_server_form.pas
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface
Vcl.StdCtrls, Vcl.Buttons, System.StrUtils, System.Types,
{$ELSE}
SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons,
StdCtrls, StrUtils,
StdCtrls, StrUtils, Windows,
{$ENDIF}
Contnrs, RunningThread, SimpMath, Math3d, downhill_simplex_handler;

Expand Down Expand Up @@ -733,6 +733,8 @@ procedure TBoundingBoxServerForm.FindGlobalMinVolume;
Handler: TDownHillSimplexHandler;
Runners: TComponentList;
Runner: TRunner;
fPerformanceFrequency, fStartTime, fEndTime: Int64;
FComputationTime: single;
begin
fRuns := 3;
if PointCloud.Count < 100000 then
Expand All @@ -741,6 +743,12 @@ procedure TBoundingBoxServerForm.FindGlobalMinVolume;
fRuns := 9;
FBoxVolume := 1e30;

{ Initializing performance counters. }
fPerformanceFrequency := 0;
fStartTime := 0;
fEndTime := 0;
QueryPerformanceFrequency(fPerformanceFrequency);
QueryPerformanceCounter(fStartTime);
Runners := TComponentList.Create(True);
for i := 0 to fRuns - 1 do
begin
Expand Down Expand Up @@ -777,10 +785,15 @@ procedure TBoundingBoxServerForm.FindGlobalMinVolume;
end;
Runners.Free;

QueryPerformanceCounter(fEndTime);
FComputationTime:= 0;
if fPerformanceFrequency <> 0 then
FComputationTime := (fEndTime - fStartTime) / fPerformanceFrequency;
FOptiResultBoxVolume := FBoxVolume;
FOptiResultBoxMaxCoords := FMaxCoords;
FOptiResultBoxMinCoords := FMinCoords;
OutputResults;
Memo1.Lines.Add('Full Calc Time : ' + Format(' %.4f', [FComputationTime]));
end;

procedure TBoundingBoxServerForm.LoadObjPointCloud(iFileName: string;
Expand Down

0 comments on commit ef22bbe

Please sign in to comment.