source upload
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- BEGIN_INCLUDE(manifest) -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="%package%"
|
||||
android:versionCode="%versionCode%"
|
||||
android:versionName="%versionName%"
|
||||
android:installLocation="%installLocation%">
|
||||
|
||||
<uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" />
|
||||
<%uses-permission%>
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="True"/>
|
||||
<application android:persistent="%persistent%"
|
||||
android:restoreAnyVersion="%restoreAnyVersion%"
|
||||
android:label="%label%"
|
||||
android:debuggable="%debuggable%"
|
||||
android:largeHeap="%largeHeap%"
|
||||
android:icon="%icon%"
|
||||
android:theme="%theme%"
|
||||
android:hardwareAccelerated="%hardwareAccelerated%"
|
||||
android:resizeableActivity="false"
|
||||
android:requestLegacyExternalStorage="true">
|
||||
|
||||
<%provider%>
|
||||
<%application-meta-data%>
|
||||
<%uses-libraries%>
|
||||
<%services%>
|
||||
<!-- Our activity is a subclass of the built-in NativeActivity framework class.
|
||||
This will take care of integrating with our NDK code. -->
|
||||
<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
|
||||
android:label="%activityLabel%"
|
||||
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
|
||||
android:launchMode="singleTask">
|
||||
<!-- Tell NativeActivity the name of our .so -->
|
||||
<meta-data android:name="android.app.lib_name"
|
||||
android:value="%libNameValue%" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<%activity%>
|
||||
<%receivers%>
|
||||
</application>
|
||||
</manifest>
|
||||
<!-- END_INCLUDE(manifest) -->
|
After Width: | Height: | Size: 282 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 580 KiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 151 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 7.2 KiB |
@@ -0,0 +1,261 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Condition="Exists('$(BDS)\bin\CodeGear.Deployment.targets')" Project="$(BDS)\bin\CodeGear.Deployment.targets"/>
|
||||
<ProjectExtensions>
|
||||
<ProjectFileVersion>12</ProjectFileVersion>
|
||||
</ProjectExtensions>
|
||||
<PropertyGroup>
|
||||
<DeviceId Condition="'$(Platform)'=='Android'"/>
|
||||
<DeviceId Condition="'$(Platform)'=='Android64'">CB512EA59X</DeviceId>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="'$(Platform)'=='Win32'">
|
||||
<DeployFile Include="Win32\Debug\HashBenchmark.exe" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\</RemoteDir>
|
||||
<RemoteName>HashBenchmark.exe</RemoteName>
|
||||
<DeployClass>ProjectOutput</DeployClass>
|
||||
<Operation>0</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
<Required>True</Required>
|
||||
</DeployFile>
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Platform)'=='Win64'"/>
|
||||
<ItemGroup Condition="'$(Platform)'=='Android'"/>
|
||||
<ItemGroup Condition="'$(Platform)'=='Android64'">
|
||||
<DeployFile Include="Crypto_426_320.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-small\</RemoteDir>
|
||||
<RemoteName>splash_image.png</RemoteName>
|
||||
<DeployClass>Android_SplashImage426</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_48x48.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-xhdpi\</RemoteDir>
|
||||
<RemoteName>ic_notification.png</RemoteName>
|
||||
<DeployClass>Android_NotificationIcon48</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Hash36.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-ldpi\</RemoteDir>
|
||||
<RemoteName>ic_launcher.png</RemoteName>
|
||||
<DeployClass>Android_LauncherIcon36</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_96x96.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-xxxhdpi\</RemoteDir>
|
||||
<RemoteName>ic_notification.png</RemoteName>
|
||||
<DeployClass>Android_NotificationIcon96</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_72x72.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-xxhdpi\</RemoteDir>
|
||||
<RemoteName>ic_notification.png</RemoteName>
|
||||
<DeployClass>Android_NotificationIcon72</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="$(BDS)\lib\android\debug\armeabi-v7a\libnative-activity.so" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\library\lib\armeabi-v7a\</RemoteDir>
|
||||
<RemoteName>libHashBenchmark.so</RemoteName>
|
||||
<DeployClass>AndroidLibnativeArmeabiv7aFile</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Hash144.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-xxhdpi\</RemoteDir>
|
||||
<RemoteName>ic_launcher.png</RemoteName>
|
||||
<DeployClass>Android_LauncherIcon144</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="$(BDS)\lib\android\debug\mips\libnative-activity.so" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\library\lib\mips\</RemoteDir>
|
||||
<RemoteName>libHashBenchmark.so</RemoteName>
|
||||
<DeployClass>AndroidLibnativeMipsFile</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="$(BDS)\lib\android\debug\armeabi\libnative-activity.so" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\library\lib\armeabi\</RemoteDir>
|
||||
<RemoteName>libHashBenchmark.so</RemoteName>
|
||||
<DeployClass>AndroidLibnativeArmeabiFile</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Crypto_470_320.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-normal\</RemoteDir>
|
||||
<RemoteName>splash_image.png</RemoteName>
|
||||
<DeployClass>Android_SplashImage470</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Hash96.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-xhdpi\</RemoteDir>
|
||||
<RemoteName>ic_launcher.png</RemoteName>
|
||||
<DeployClass>Android_LauncherIcon96</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Android64\Debug\colors.xml" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\values\</RemoteDir>
|
||||
<RemoteName>colors.xml</RemoteName>
|
||||
<DeployClass>Android_Colors</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Android64\Debug\AndroidManifest.xml" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\</RemoteDir>
|
||||
<RemoteName>AndroidManifest.xml</RemoteName>
|
||||
<DeployClass>ProjectAndroidManifest</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Android64\Debug\styles.xml" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\values\</RemoteDir>
|
||||
<RemoteName>styles.xml</RemoteName>
|
||||
<DeployClass>AndroidSplashStyles</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_24x24.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-mdpi\</RemoteDir>
|
||||
<RemoteName>ic_notification.png</RemoteName>
|
||||
<DeployClass>Android_NotificationIcon24</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_36x36.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-hdpi\</RemoteDir>
|
||||
<RemoteName>ic_notification.png</RemoteName>
|
||||
<DeployClass>Android_NotificationIcon36</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Android64\Debug\splash_image_def.xml" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable\</RemoteDir>
|
||||
<RemoteName>splash_image_def.xml</RemoteName>
|
||||
<DeployClass>AndroidSplashImageDef</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Android64\Debug\libHashBenchmark.so" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\library\lib\arm64-v8a\</RemoteDir>
|
||||
<RemoteName>libHashBenchmark.so</RemoteName>
|
||||
<DeployClass>ProjectOutput</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
<Required>True</Required>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Android64\Debug\classes.dex" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\classes\</RemoteDir>
|
||||
<RemoteName>classes.dex</RemoteName>
|
||||
<DeployClass>AndroidClassesDexFile</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Crypto_640_480.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-large\</RemoteDir>
|
||||
<RemoteName>splash_image.png</RemoteName>
|
||||
<DeployClass>Android_SplashImage640</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Hash72.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-hdpi\</RemoteDir>
|
||||
<RemoteName>ic_launcher.png</RemoteName>
|
||||
<DeployClass>Android_LauncherIcon72</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Android64\Debug\styles-v21.xml" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\values-v21\</RemoteDir>
|
||||
<RemoteName>styles.xml</RemoteName>
|
||||
<DeployClass>AndroidSplashStylesV21</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Android64\Debug\strings.xml" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\values\</RemoteDir>
|
||||
<RemoteName>strings.xml</RemoteName>
|
||||
<DeployClass>Android_Strings</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Hash48.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-mdpi\</RemoteDir>
|
||||
<RemoteName>ic_launcher.png</RemoteName>
|
||||
<DeployClass>Android_LauncherIcon48</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Crypto_960_720.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-xlarge\</RemoteDir>
|
||||
<RemoteName>splash_image.png</RemoteName>
|
||||
<DeployClass>Android_SplashImage960</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
<DeployFile Include="Hash192.png" Condition="'$(Config)'=='Debug'">
|
||||
<RemoteDir>HashBenchmark\res\drawable-xxxhdpi\</RemoteDir>
|
||||
<RemoteName>ic_launcher.png</RemoteName>
|
||||
<DeployClass>Android_LauncherIcon192</DeployClass>
|
||||
<Operation>1</Operation>
|
||||
<LocalCommand/>
|
||||
<RemoteCommand/>
|
||||
<Overwrite>True</Overwrite>
|
||||
</DeployFile>
|
||||
</ItemGroup>
|
||||
</Project>
|
@@ -0,0 +1,14 @@
|
||||
program HashBenchmark;
|
||||
|
||||
uses
|
||||
System.StartUpCopy,
|
||||
FMX.Forms,
|
||||
MainForm in 'MainForm.pas' {FormMain};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TFormMain, FormMain);
|
||||
Application.Run;
|
||||
end.
|
@@ -0,0 +1,77 @@
|
||||
object FormMain: TFormMain
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Hash benchmark'
|
||||
ClientHeight = 480
|
||||
ClientWidth = 640
|
||||
FormFactor.Width = 320
|
||||
FormFactor.Height = 480
|
||||
FormFactor.Devices = [Desktop]
|
||||
OnCreate = FormCreate
|
||||
OnResize = FormResize
|
||||
DesignerMasterStyle = 0
|
||||
object Rectangle1: TRectangle
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Fill.Color = claCadetblue
|
||||
HitTest = False
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 8.000000000000000000
|
||||
Size.Width = 625.000000000000000000
|
||||
Size.Height = 41.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
object b_Start: TButton
|
||||
Align = Client
|
||||
Size.Width = 625.000000000000000000
|
||||
Size.Height = 41.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
StyleLookup = 'playtoolbutton'
|
||||
TabOrder = 0
|
||||
Text = 'b_Start'
|
||||
OnClick = b_StartClick
|
||||
end
|
||||
end
|
||||
object sg_Results: TStringGrid
|
||||
Anchors = [akLeft, akTop, akRight, akBottom]
|
||||
CanFocus = True
|
||||
ClipChildren = True
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 56.000000000000000000
|
||||
Size.Width = 625.000000000000000000
|
||||
Size.Height = 369.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
StyleLookup = 'gridstyle'
|
||||
TabOrder = 0
|
||||
RowCount = 0
|
||||
Options = [ColumnResize, ColLines, RowLines, RowSelect, Tabs, Header]
|
||||
Viewport.Width = 621.000000000000000000
|
||||
Viewport.Height = 344.000000000000000000
|
||||
object StringColumn1: TStringColumn
|
||||
Header = 'Algorithm'
|
||||
ReadOnly = True
|
||||
end
|
||||
object StringColumn2: TStringColumn
|
||||
Header = 'Speed MB/s'
|
||||
end
|
||||
object StringColumn3: TStringColumn
|
||||
Header = 'Time (hh:mm:ss:ms)'
|
||||
end
|
||||
end
|
||||
object TimerBenchmark: TTimer
|
||||
Enabled = False
|
||||
Interval = 50
|
||||
OnTimer = TimerBenchmarkTimer
|
||||
Left = 408
|
||||
Top = 96
|
||||
end
|
||||
object b_CopyToClipboard: TButton
|
||||
Anchors = [akLeft, akRight, akBottom]
|
||||
Position.X = 8.000000000000000000
|
||||
Position.Y = 432.000000000000000000
|
||||
Size.Width = 625.000000000000000000
|
||||
Size.Height = 41.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 5
|
||||
Text = 'Copy to clipboard'
|
||||
OnClick = b_CopyToClipboardClick
|
||||
end
|
||||
end
|
@@ -0,0 +1,248 @@
|
||||
{*****************************************************************************
|
||||
The DEC team (see file NOTICE.txt) licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. A copy of this licence is found in the root directory of
|
||||
this project in the file LICENCE.txt or alternatively at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*****************************************************************************}
|
||||
unit MainForm;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Platform,
|
||||
FMX.Controls.Presentation, FMX.StdCtrls, System.Rtti,
|
||||
{$IF RTLVersion < 31}
|
||||
{$ELSE}
|
||||
FMX.Grid.Style,
|
||||
{$ENDIF}
|
||||
FMX.Grid, FMX.ScrollBox, FMX.Objects, System.Diagnostics;
|
||||
|
||||
type
|
||||
TFormMain = class(TForm)
|
||||
b_Start: TButton;
|
||||
sg_Results: TStringGrid;
|
||||
StringColumn1: TStringColumn;
|
||||
StringColumn2: TStringColumn;
|
||||
StringColumn3: TStringColumn;
|
||||
Rectangle1: TRectangle;
|
||||
TimerBenchmark: TTimer;
|
||||
b_CopyToClipboard: TButton;
|
||||
procedure b_StartClick(Sender: TObject);
|
||||
procedure TimerBenchmarkTimer(Sender: TObject);
|
||||
procedure FormResize(Sender: TObject);
|
||||
procedure b_CopyToClipboardClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
private
|
||||
/// <summary>
|
||||
/// Data which is being hashed for the benchmark
|
||||
/// </summary>
|
||||
FBenchmarkBuffer : TBytes;
|
||||
/// <summary>
|
||||
/// Stopwatch used
|
||||
/// </summary>
|
||||
FStopwatch : TStopwatch;
|
||||
/// <summary>
|
||||
/// Currently processed gridrow
|
||||
/// </summary>
|
||||
FRowIndex : Integer;
|
||||
|
||||
/// <summary>
|
||||
/// Runs the benchmark for a single class
|
||||
/// </summary>
|
||||
/// <param name="ClassName">
|
||||
/// Name of the class to benchmark
|
||||
/// </param>
|
||||
/// <param name="RowIndex">
|
||||
/// Number of the row where the results are to be displayed
|
||||
/// </param>
|
||||
procedure RunBenchmark(ClassName: string;
|
||||
RowIndex: Integer);
|
||||
/// <summary>
|
||||
/// Try to get access to the clipboard service
|
||||
/// </summary>
|
||||
/// <param name="ClipBoardInterface">
|
||||
/// Interface reference for accessing the clipboard if Result is true
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// True when access to the clipboard could be aquired
|
||||
/// </returns>
|
||||
function TryGetClipboardService(out ClipboardService: IFMXClipboardService): Boolean;
|
||||
/// <summary>
|
||||
/// Put a string into the clipboard, if possible
|
||||
/// </summary>
|
||||
/// <param name="s">
|
||||
/// String to store into the clipboard
|
||||
/// </param>
|
||||
procedure StringToClipboard(const s: string);
|
||||
public
|
||||
end;
|
||||
|
||||
var
|
||||
FormMain: TFormMain;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Generics.Collections,
|
||||
DECBaseClass, DECHashBase, DECHash;
|
||||
|
||||
const
|
||||
/// <summary>
|
||||
/// Number of times the buffer will be calculated a hash over
|
||||
/// </summary>
|
||||
cIterations = 10;
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
function TFormMain.TryGetClipboardService(out ClipboardService: IFMXClipboardService): Boolean;
|
||||
begin
|
||||
Result := TPlatformServices.Current.SupportsPlatformService(IFMXClipboardService);
|
||||
if Result then
|
||||
ClipboardService := IFMXClipboardService(TPlatformServices.Current.GetPlatformService(IFMXClipboardService));
|
||||
end;
|
||||
|
||||
procedure TFormMain.StringToClipboard(const s: string);
|
||||
var
|
||||
clp: IFMXClipboardService;
|
||||
begin
|
||||
if TryGetClipboardService(clp) then
|
||||
clp.SetClipboard(s);
|
||||
end;
|
||||
|
||||
procedure TFormMain.b_CopyToClipboardClick(Sender: TObject);
|
||||
var
|
||||
s : string;
|
||||
row, col: Integer;
|
||||
begin
|
||||
s := '';
|
||||
|
||||
for col := 0 to sg_Results.ColumnCount - 1 do
|
||||
s := s + sg_Results.Columns[col].Header + FormatSettings.ListSeparator;
|
||||
|
||||
s := s + sLineBreak;
|
||||
|
||||
for row := 0 to sg_Results.RowCount - 1 do
|
||||
begin
|
||||
for col := 0 to sg_Results.ColumnCount - 1 do
|
||||
s := s + sg_Results.Cells[col, row] + FormatSettings.ListSeparator;
|
||||
|
||||
s := s + sLineBreak;
|
||||
end;
|
||||
|
||||
StringToClipboard(s);
|
||||
end;
|
||||
|
||||
procedure TFormMain.b_StartClick(Sender: TObject);
|
||||
var
|
||||
ClassNames : TStringList;
|
||||
ClassName : string;
|
||||
i, n : Integer;
|
||||
begin
|
||||
b_CopyToClipboard.Enabled := false;
|
||||
sg_Results.RowCount := 0;
|
||||
// Create 1 MB Buffer
|
||||
SetLength(FBenchmarkBuffer, 1024*1024);
|
||||
|
||||
n := 0;
|
||||
for i := 0 to Length(FBenchmarkBuffer)-1 do
|
||||
begin
|
||||
FBenchmarkBuffer[i] := n;
|
||||
inc(n);
|
||||
|
||||
if (n > 255) then
|
||||
n := 0;
|
||||
end;
|
||||
|
||||
ClassNames := TStringList.Create;
|
||||
|
||||
try
|
||||
TDECHash.ClassList.GetClassList(ClassNames);
|
||||
ClassNames.Sort;
|
||||
|
||||
for ClassName in ClassNames do
|
||||
begin
|
||||
sg_Results.RowCount := sg_Results.RowCount + 1;
|
||||
sg_Results.Cells[0, sg_Results.RowCount - 1] := ClassName;
|
||||
end;
|
||||
|
||||
FRowIndex := 0;
|
||||
FStopwatch := TStopwatch.Create;
|
||||
TimerBenchmark.Enabled := true;
|
||||
finally
|
||||
ClassNames.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFormMain.FormCreate(Sender: TObject);
|
||||
begin
|
||||
b_CopyToClipboard.Enabled := false;
|
||||
|
||||
// This property is only supported from 10.4 onwards, so we set it in code
|
||||
{$IF RTLVersion >= 34}
|
||||
StringColumn2.HorzAlign := TTextAlign.Trailing;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TFormMain.FormResize(Sender: TObject);
|
||||
var
|
||||
i : Integer;
|
||||
w : Single;
|
||||
begin
|
||||
w := sg_Results.Width / sg_Results.ColumnCount;
|
||||
|
||||
for i := 0 to sg_Results.ColumnCount - 1 do
|
||||
sg_Results.Columns[i].Width := w;
|
||||
end;
|
||||
|
||||
procedure TFormMain.RunBenchmark(ClassName: string; RowIndex: Integer);
|
||||
var
|
||||
Hash : TDECHash;
|
||||
HashResult : TBytes;
|
||||
i : Integer;
|
||||
begin
|
||||
Hash := TDECHash.ClassByName(ClassName).Create;
|
||||
|
||||
try
|
||||
FStopwatch.Reset;
|
||||
FStopwatch.Start;
|
||||
|
||||
for i := 0 to cIterations - 1 do
|
||||
begin
|
||||
HashResult := Hash.CalcBytes(FBenchmarkBuffer);
|
||||
end;
|
||||
|
||||
FStopwatch.Stop;
|
||||
|
||||
sg_Results.Cells[1, RowIndex] :=
|
||||
Format('%0:f', [cIterations / (FStopwatch.ElapsedMilliseconds/1000)]);
|
||||
sg_Results.Cells[2, RowIndex] := FStopwatch.Elapsed;
|
||||
finally
|
||||
Hash.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFormMain.TimerBenchmarkTimer(Sender: TObject);
|
||||
begin
|
||||
(Sender as TTimer).Enabled := false;
|
||||
|
||||
RunBenchmark(sg_Results.Cells[0, FRowIndex], FRowIndex);
|
||||
Inc(FRowIndex);
|
||||
|
||||
if (FRowIndex < sg_Results.RowCount) then
|
||||
(Sender as TTimer).Enabled := true
|
||||
else
|
||||
b_CopyToClipboard.Enabled := true;
|
||||
end;
|
||||
|
||||
end.
|