mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-27 19:42:22 -05:00
Simba: Add MMLBenchmark project.
This commit is contained in:
parent
f2873b1f1c
commit
989d077e44
BIN
Projects/MMLBenchmark/project1.ico
Normal file
BIN
Projects/MMLBenchmark/project1.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
199
Projects/MMLBenchmark/project1.lpi
Normal file
199
Projects/MMLBenchmark/project1.lpi
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<CONFIG>
|
||||||
|
<ProjectOptions>
|
||||||
|
<Version Value="9"/>
|
||||||
|
<General>
|
||||||
|
<Flags>
|
||||||
|
<MainUnitHasCreateFormStatements Value="False"/>
|
||||||
|
</Flags>
|
||||||
|
<MainUnit Value="0"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
<UseXPManifest Value="True"/>
|
||||||
|
<Icon Value="0"/>
|
||||||
|
<ActiveWindowIndexAtStart Value="0"/>
|
||||||
|
</General>
|
||||||
|
<i18n>
|
||||||
|
<EnableI18N LFM="False"/>
|
||||||
|
</i18n>
|
||||||
|
<VersionInfo>
|
||||||
|
<StringTable ProductVersion=""/>
|
||||||
|
</VersionInfo>
|
||||||
|
<BuildModes Count="1" Active="Default">
|
||||||
|
<Item1 Name="Default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||||
|
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<local>
|
||||||
|
<FormatVersion Value="1"/>
|
||||||
|
</local>
|
||||||
|
</RunParams>
|
||||||
|
<Units Count="6">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
<UnitName Value="project1"/>
|
||||||
|
<IsVisibleTab Value="True"/>
|
||||||
|
<EditorIndex Value="0"/>
|
||||||
|
<WindowIndex Value="0"/>
|
||||||
|
<TopLine Value="47"/>
|
||||||
|
<CursorPos X="25" Y="58"/>
|
||||||
|
<UsageCount Value="20"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit0>
|
||||||
|
<Unit1>
|
||||||
|
<Filename Value="../../Units/MMLCore/client.pas"/>
|
||||||
|
<UnitName Value="Client"/>
|
||||||
|
<EditorIndex Value="4"/>
|
||||||
|
<WindowIndex Value="0"/>
|
||||||
|
<TopLine Value="1"/>
|
||||||
|
<CursorPos X="89" Y="10"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit1>
|
||||||
|
<Unit2>
|
||||||
|
<Filename Value="../../../fpc/packages/fcl-base/src/custapp.pp"/>
|
||||||
|
<UnitName Value="CustApp"/>
|
||||||
|
<WindowIndex Value="0"/>
|
||||||
|
<TopLine Value="42"/>
|
||||||
|
<CursorPos X="14" Y="63"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
</Unit2>
|
||||||
|
<Unit3>
|
||||||
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
|
<UnitName Value="bitmaps"/>
|
||||||
|
<EditorIndex Value="2"/>
|
||||||
|
<WindowIndex Value="0"/>
|
||||||
|
<TopLine Value="863"/>
|
||||||
|
<CursorPos X="12" Y="883"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit3>
|
||||||
|
<Unit4>
|
||||||
|
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
|
||||||
|
<UnitName Value="os_linux"/>
|
||||||
|
<EditorIndex Value="3"/>
|
||||||
|
<WindowIndex Value="0"/>
|
||||||
|
<TopLine Value="9"/>
|
||||||
|
<CursorPos X="79" Y="32"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit4>
|
||||||
|
<Unit5>
|
||||||
|
<Filename Value="../../Units/MMLCore/colour_conv.pas"/>
|
||||||
|
<UnitName Value="colour_conv"/>
|
||||||
|
<EditorIndex Value="1"/>
|
||||||
|
<WindowIndex Value="0"/>
|
||||||
|
<TopLine Value="12"/>
|
||||||
|
<CursorPos X="60" Y="33"/>
|
||||||
|
<UsageCount Value="10"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
</Unit5>
|
||||||
|
</Units>
|
||||||
|
<JumpHistory Count="15" HistoryIndex="14">
|
||||||
|
<Position1>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="34" Column="11" TopLine="13"/>
|
||||||
|
</Position1>
|
||||||
|
<Position2>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="42" Column="21" TopLine="13"/>
|
||||||
|
</Position2>
|
||||||
|
<Position3>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="34" Column="11" TopLine="1"/>
|
||||||
|
</Position3>
|
||||||
|
<Position4>
|
||||||
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
|
<Caret Line="1" Column="1" TopLine="1"/>
|
||||||
|
</Position4>
|
||||||
|
<Position5>
|
||||||
|
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
|
||||||
|
<Caret Line="1" Column="1" TopLine="1"/>
|
||||||
|
</Position5>
|
||||||
|
<Position6>
|
||||||
|
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
|
||||||
|
<Caret Line="34" Column="103" TopLine="8"/>
|
||||||
|
</Position6>
|
||||||
|
<Position7>
|
||||||
|
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
|
||||||
|
<Caret Line="29" Column="64" TopLine="8"/>
|
||||||
|
</Position7>
|
||||||
|
<Position8>
|
||||||
|
<Filename Value="../../Units/MMLCore/colour_conv.pas"/>
|
||||||
|
<Caret Line="1" Column="1" TopLine="1"/>
|
||||||
|
</Position8>
|
||||||
|
<Position9>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="10" Column="48" TopLine="1"/>
|
||||||
|
</Position9>
|
||||||
|
<Position10>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="17" Column="45" TopLine="1"/>
|
||||||
|
</Position10>
|
||||||
|
<Position11>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="34" Column="19" TopLine="13"/>
|
||||||
|
</Position11>
|
||||||
|
<Position12>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="40" Column="20" TopLine="25"/>
|
||||||
|
</Position12>
|
||||||
|
<Position13>
|
||||||
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
|
<Caret Line="27" Column="82" TopLine="1"/>
|
||||||
|
</Position13>
|
||||||
|
<Position14>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="34" Column="16" TopLine="20"/>
|
||||||
|
</Position14>
|
||||||
|
<Position15>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="43" Column="32" TopLine="24"/>
|
||||||
|
</Position15>
|
||||||
|
</JumpHistory>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="10"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="project1"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<OtherUnitFiles Value="../../Units/MMLCore;../../Units/Linux;../../Units/Misc;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS);$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType);$(LazarusDir)/components/mouseandkeyinput"/>
|
||||||
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<CodeGeneration>
|
||||||
|
<Optimizations>
|
||||||
|
<OptimizationLevel Value="3"/>
|
||||||
|
</Optimizations>
|
||||||
|
</CodeGeneration>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<GenerateDebugInfo Value="True"/>
|
||||||
|
</Debugging>
|
||||||
|
</Linking>
|
||||||
|
<Other>
|
||||||
|
<CompilerMessages>
|
||||||
|
<UseMsgFile Value="True"/>
|
||||||
|
</CompilerMessages>
|
||||||
|
<CompilerPath Value="$(CompPath)"/>
|
||||||
|
</Other>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="3">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item3>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
139
Projects/MMLBenchmark/project1.lpr
Normal file
139
Projects/MMLBenchmark/project1.lpr
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
program project1;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
uses
|
||||||
|
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||||
|
cthreads,
|
||||||
|
{$ENDIF}{$ENDIF}
|
||||||
|
Classes, SysUtils, CustApp,
|
||||||
|
interfaces, // to prevent linking errors. :|
|
||||||
|
|
||||||
|
client, MufasaTypes,
|
||||||
|
|
||||||
|
lclintf;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TMMLBenchmark }
|
||||||
|
|
||||||
|
TMMLBenchmark = class(TCustomApplication)
|
||||||
|
protected
|
||||||
|
procedure DoRun; override;
|
||||||
|
public
|
||||||
|
constructor Create(TheOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure WriteHelp; virtual;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
bmp: Integer;
|
||||||
|
|
||||||
|
MMLClient: TClient;
|
||||||
|
{ TMMLBenchmark }
|
||||||
|
|
||||||
|
procedure init;
|
||||||
|
|
||||||
|
begin
|
||||||
|
MMLClient := TClient.Create('');
|
||||||
|
|
||||||
|
bmp := MMLClient.MBitmaps.CreateBMP(0, 0);
|
||||||
|
MMLClient.MBitmaps.GetBMP(bmp).LoadFromFile('/home/merlijn/Programs/simba/wall.bmp');
|
||||||
|
MMLClient.IOManager.SetTarget(MMLClient.MBitmaps[bmp]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure free;
|
||||||
|
begin
|
||||||
|
MMLClient.IOManager.SetDesktop;
|
||||||
|
MMLClient.MBitmaps.FreeBMP(bmp);
|
||||||
|
MMLClient.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure Benchmark;
|
||||||
|
|
||||||
|
var
|
||||||
|
t, t2, t3: PtrUInt;
|
||||||
|
i, c, w, h: integer;
|
||||||
|
col, tol: integer;
|
||||||
|
|
||||||
|
dummytpa: TPointArray;
|
||||||
|
|
||||||
|
begin
|
||||||
|
init;
|
||||||
|
t := gettickcount;
|
||||||
|
MMLClient.IOManager.GetDimensions(w, h);
|
||||||
|
|
||||||
|
col := 16777215; tol := 30;
|
||||||
|
|
||||||
|
for c := 0 to 2 do // benchmark all CTS'es
|
||||||
|
begin
|
||||||
|
MMLClient.MFinder.SetToleranceSpeed(c);
|
||||||
|
t2 := gettickcount;
|
||||||
|
for i := 0 to 100 do
|
||||||
|
begin
|
||||||
|
MMLClient.MFinder.FindColorsTolerance(dummytpa, col, 0, 0, w-1,h-1, tol);
|
||||||
|
end;
|
||||||
|
t3 := gettickcount;
|
||||||
|
writeln(format('FindColorsTolerance'+#10+
|
||||||
|
'Time spent: %d ms (per %f ms), matches: %d, CTS: %d, Colour: %d, Tolerance %d',
|
||||||
|
[t3-t2, (t3-t2) / 100.0, length(dummytpa), c, col, tol]));
|
||||||
|
end;
|
||||||
|
|
||||||
|
free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMMLBenchmark.DoRun;
|
||||||
|
var
|
||||||
|
ErrorMsg: String;
|
||||||
|
begin
|
||||||
|
// quick check parameters
|
||||||
|
ErrorMsg:=CheckOptions('h','help');
|
||||||
|
if ErrorMsg<>'' then begin
|
||||||
|
ShowException(Exception.Create(ErrorMsg));
|
||||||
|
Terminate;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// parse parameters
|
||||||
|
if HasOption('h','help') then begin
|
||||||
|
WriteHelp;
|
||||||
|
Terminate;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
Benchmark;
|
||||||
|
|
||||||
|
{ add your program here }
|
||||||
|
|
||||||
|
// stop program loop
|
||||||
|
Terminate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TMMLBenchmark.Create(TheOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(TheOwner);
|
||||||
|
StopOnException:=True;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TMMLBenchmark.Destroy;
|
||||||
|
begin
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMMLBenchmark.WriteHelp;
|
||||||
|
begin
|
||||||
|
{ add your help code here }
|
||||||
|
writeln('Usage: ',ExeName,' -h');
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Application: TMMLBenchmark;
|
||||||
|
|
||||||
|
{$R *.res}
|
||||||
|
|
||||||
|
begin
|
||||||
|
Application:=TMMLBenchmark.Create(nil);
|
||||||
|
Application.Run;
|
||||||
|
Application.Free;
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user