unit Forms.MainForm;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls;
type
TForm1 =
class( TForm )
Button1: TButton;
Button2: TButton;
procedure Button1Click( Sender: TObject );
procedure Button2Click( Sender: TObject );
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
System.Diagnostics,
Types.MyTypes, Types.MyClassTypes;
procedure TForm1.Button1Click( Sender: TObject );
var
AllDataList : TMyListe;
FirstList : TMyListe;
i : Integer;
aData : TMyData;
aMes1, aMes2: TStopWatch;
begin
AllDataList := TMyListe.Create;
FirstList := TMyListe.Create;
aMes1.Create;
aMes1.Reset;
aMes1.Start;
try
// 5000 Einträge erstellen (First=True)
for i := 1
to 5000
do
begin
aData.Clear;
aData.ID := i;
aData.First := True;
AllDataList.Add( aData );
end;
// 5000 Einträge erstellen (First=False)
for i := 1
to 5000
do
begin
aData.Clear;
aData.ID2 := i;
aData.First := False;
AllDataList.Add( aData );
end;
// Schritt1: Rootliste füllen
aMes2.Create;
aMes2.Reset;
aMes2.Start;
AllDataList.GetFirstItems( FirstList );
aMes2.Stop;
finally
if Assigned( FirstList )
then
begin
FirstList.Clear;
FreeAndNil( FirstList );
end;
if Assigned( AllDataList )
then
begin
AllDataList.Clear;
FreeAndNil( AllDataList );
end;
end;
aMes1.Stop;
ShowMessage( '
Zeitmessung 1 (s): ' + IntToStr( Round( aMes1.ElapsedMilliseconds / 1000 ) ) );
ShowMessage( '
Zeitmessung 2 (s): ' + IntToStr( Round( aMes2.ElapsedMilliseconds / 1000 ) ) );
end;
procedure TForm1.Button2Click( Sender: TObject );
var
AllDataList : TMyObjListe;
FirstList : TMyObjListe;
i : Integer;
aData : TMyDataObj;
aMes1, aMes2: TStopWatch;
begin
AllDataList := TMyObjListe.Create( True );
FirstList := TMyObjListe.Create( True );
aMes1.Create;
aMes1.Reset;
aMes1.Start;
try
// 5000 Einträge erstellen (First=True)
for i := 1
to 5000
do
begin
aData := TMyDataObj.Create;
aData.ID := i;
aData.First := True;
AllDataList.Add( aData );
end;
// 5000 Einträge erstellen (First=False)
for i := 1
to 5000
do
begin
aData := TMyDataObj.Create;
aData.ID2 := i;
aData.First := False;
AllDataList.Add( aData );
end;
// Schritt1: Rootliste füllen
aMes2.Create;
aMes2.Reset;
aMes2.Start;
AllDataList.GetFirstItems( FirstList );
aMes2.Stop;
finally
FreeAndNil( FirstList );
FreeAndNil( AllDataList );
end;
aMes1.Stop;
ShowMessage( '
Zeitmessung 1 (s): ' + IntToStr( Round( aMes1.ElapsedMilliseconds / 1000 ) ) );
ShowMessage( '
Zeitmessung 2 (s): ' + IntToStr( Round( aMes2.ElapsedMilliseconds / 1000 ) ) );
end;
end.