我的机器 0.0063-0.0078s 应该再没什么讨论的了吧 最快的就是指针
procedure TForm4.Button2Click(Sender: TObject);
var
iLength: integer;
i1, i2, i3, i4, i5, i6, i7: Byte;
time: DWORD;
p: pointer;
pb
Byte;
begin
time := GetTickCount;
ilength := 8347680;
p := GetMemory(iLength * 7);
pb := p;
for i1 := 1 to 30 do
for i2 := i1 + 1 to 31 do
for i3 := i2 + 1 to 32 do
for i4 := i3 + 1 to 33 do
for i5 := i4 + 1 to 34 do
for i6 := i5 + 1 to 35 do
for i7 := i6 + 1 to 36 do
begin
Pb^:= i1
Inc(Pb);
Pb^:= i2
Inc(Pb);
Pb^:= i3
Inc(Pb);
Pb^:= i4
Inc(Pb);
Pb^:= i5
Inc(Pb);
Pb^:= i6
Inc(Pb);
Pb^:= i7
Inc(Pb);
end;
time := GetTickCount - time;
Edit2.Text := '用时:' + IntToStr(Time) + 'ms';
freeMem(p, iLength * 7);
end;
Unit4.pas.61: with pData^ do begin
004A643E 8BC1 mov eax,ecx
Unit4.pas.62: data[0] := i1;
004A6440 0FB65DF4 movzx ebx,[ebp-$0c]
004A6444 8818 mov [eax],bl
Unit4.pas.63: data[1] := i2;
004A6446 0FB65DF0 movzx ebx,[ebp-$10]
004A644A 885801 mov [eax+$01],bl
Unit4.pas.64: data[2] := i3;
004A644D 0FB65DEC movzx ebx,[ebp-$14]
004A6451 885802 mov [eax+$02],bl
Unit4.pas.65: data[3] := i4;
004A6454 0FB65DE8 movzx ebx,[ebp-$18]
004A6458 885803 mov [eax+$03],bl
Unit4.pas.66: data[4] := i5;
004A645B 0FB65DE4 movzx ebx,[ebp-$1c]
004A645F 885804 mov [eax+$04],bl
Unit4.pas.67: data[5] := i6;
004A6462 8BDE mov ebx,esi
004A6464 885805 mov [eax+$05],bl
Unit4.pas.68: data[6] := i7;
004A6467 885006 mov [eax+$06],dl
Unit4.pas.70: inc(pData);
004A646A 83C107 add ecx,$07
Unit4.pas.71: end;
004A646D 42 inc edx
Unit4.pas.98: Pb^ := i1
Inc(Pb);
004A65DE 0FB64DF7 movzx ecx,[ebp-$09]
004A65E2 880E mov [esi],cl
004A65E4 46 inc esi
Unit4.pas.99: Pb^ := i2
Inc(Pb);
004A65E5 0FB64DF6 movzx ecx,[ebp-$0a]
004A65E9 880E mov [esi],cl
004A65EB 46 inc esi
Unit4.pas.100: Pb^ := i3
Inc(Pb);
004A65EC 0FB64DF5 movzx ecx,[ebp-$0b]
004A65F0 880E mov [esi],cl
004A65F2 46 inc esi
Unit4.pas.101: Pb^ := i4
Inc(Pb);
004A65F3 0FB64DF4 movzx ecx,[ebp-$0c]
004A65F7 880E mov [esi],cl
004A65F9 46 inc esi
Unit4.pas.102: Pb^ := i5
Inc(Pb);
004A65FA 0FB64DF3 movzx ecx,[ebp-$0d]
004A65FE 880E mov [esi],cl
004A6600 46 inc esi
Unit4.pas.103: Pb^ := i6
Inc(Pb);
004A6601 8806 mov [esi],al
004A6603 46 inc esi
Unit4.pas.104: Pb^ := i7
Inc(Pb);
004A6604 8816 mov [esi],dl
004A6606 46 inc esi
mov [eax+$02],bl
比
mov [esi],cl inc esi
慢多了