Накидал приложение:
- Код: Выделить всё
nit uMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
const
SIZE_TST_ARRAY = 1024*1024*10;
type
TForm1 = class(TForm)
btnBtnIntToStrTest: TButton;
btnBtnForTest: TButton;
btnBtnEmptyFillTest: TButton;
lblResult: TLabel;
lblForTst: TLabel;
lblEmptyFill: TLabel;
procedure BtnEmptyFillTestClick(Sender: TObject);
procedure BtnForTestClick(Sender: TObject);
procedure BtnIntToStrTestClick(Sender: TObject);
private
{ Private declarations }
mas: array[0..SIZE_TST_ARRAY - 1] of string;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BtnIntToStrTestClick(Sender: TObject);
var
i: int32;
ms: DWORD;
begin
ms := GetTickCount;
for i := 0 to SIZE_TST_ARRAY - 1 do
mas[i] := IntToStr(i);
lblResult.Caption := IntToStr(GetTickCount - ms);
end;
procedure TForm1.BtnForTestClick(Sender: TObject);
var
i: int32;
ms: DWORD;
begin
ms := GetTickCount;
for i := 0 to SIZE_TST_ARRAY - 1 do;
lblForTst.Caption := IntToStr(GetTickCount - ms);
end;
procedure TForm1.BtnEmptyFillTestClick(Sender: TObject);
var
i: int32;
ms: DWORD;
begin
ms := GetTickCount;
for i := 0 to SIZE_TST_ARRAY - 1 do
mas[i] := '';
lblEmptyFill.Caption := IntToStr(GetTickCount - ms);
end;
end.
Запустил из под лазаря и делфи хе5.
Результат не в пользу первого что огорчает:
- а) заполнение массива строками с вызовом IntToStr(i):
- delphi - 1139 мс;
- lazarus - 1607 мс;
б) холостой проход по циклу через for:
- delphi - 63 мс;
- lazarus - 63 мс;
в) заполнение массива пустыми строками:
- delphi - 374 мс;
- lazarus - 624 мс;