Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
Delphi 12 Athens
|
Re: dynamische Arrays vergrößern
10. Jun 2009, 20:44
Delphi-Quellcode:
var
a: Array of Integer;
aLen, i, i2, i3: Integer;
C, C2: LongWord;
begin
C := GetTickCount;
for i2 := 1 to 10000000 do begin
i := Length(a);
SetLength(a, i + 1);
a[i] := 123456;
End;
C := GetTickCount - C;
a := nil;
aLen := 0;
C2 := GetTickCount;
for i2 := 1 to 10000000 do begin
i := aLen;
Inc(aLen);
i3 := (aLen + $FF) and not $FF;
if i3 <> Length(a) then SetLength(a, i3);
a[i] := 123456;
end;
C2 := GetTickCount - C2;
Application.MessageBox(PChar(Format('C = %d ms'#13#10'C2 = %d ms', [C, C2])), 'Test');
end;
Zitat:
---------------------------
Test
---------------------------
C = 1094 ms
C2 = 78 ms
---------------------------
OK
---------------------------
$2B or not $2B
|
|
Zitat
|