Delphi 7 ;Delphi2005 VCL.net ;Delphi2005 win32;procedure TForm1.Button1Click(Sender: TObject);
var
I,L,S,K,E:DWORD;
begin
for L:=1 to 10 do
begin
S:=GetTickCount();
for I:=1 to 100000 do
begin
Self.Canvas.TextOut(10,64,IntToStr(i));
end;
E:=GetTickCount();
Self.Canvas.TextOut(80,64,IntToStr(E-S));
K:=K+(E-S);
end;
Label5.Caption:=FloatToStr(K/10);
end;//-------------------------------------------------------------------------
C++Builder 6
void __fastcall TForm1::Button1Click(TObject *Sender)
{
DWord k,s,e,L,AllCount;
k=s=e=0;
for(L=0;L<10;L++)
{
s=GetTickCount();
for (int i=0;i<100000;i++)
{
k++;
this->Canvas->TextOut(20,40,IntToStr(k));
}
e=GetTickCount();
this->Canvas->TextOut(70,40,IntToStr(e-s));
AllCount+=(e-s);
}
Label5->Caption=FloatToStr(AllCount/10.0);
}//-----------------------------------------------------------------------
Visual C++ 6
void CVCTestDlg::OnOK()
{
DWORD k,s,e,L,AllCount;
k=s=e=AllCount=0;
HDC cdc;
cdc=::GetDC(this->m_hWnd);
CString Str;
for(L=0;L<10;L++)
{
s=GetTickCount();
for (int i=0;i<100000;i++)
{
k++;
Str.Format("%d",k);
TextOut(cdc,10,40,Str,strlen(Str));
} e=GetTickCount();
Str.Format("%d",(e-s));
TextOut(cdc,100,40,Str,strlen(Str));
AllCount+=(e-s);
}
Str.Format("%f",(AllCount/10.0));
m_Caption=Str;
UpdateData(false);
}//------------------------------------------------------------------------------------------DelphiVCL.Net Mem 15944K VMem 8404K Hander 126 Thread 4 GDI 41 Test 843.7 毫秒
DelphiWin32 Mem 2888K VMem 952K Hander 28 Thread 1 GDI 29 Test 731.1
Delphi7 Mem 2824K VMem 684K Hander 28 Thread 1 GDI 31 Test 707.8
BCB6 Mem 2844K VMem 672K Hander 29 Thread 1 GDI 28 Test 804.8
VC6 Mem 2524k Vmem 792K Hander 25 Thread 1 GDI 10 Test 557.8
Delphi2005 异常内存使用高达15MB Delphi2005 Win32 K:=0; 要先初始化 而不是早默认的0 是Bug吗?
在P4 2.4G 512MB DDR333
I,L,S,K,E:DWORD;
begin
for L:=1 to 10 do
begin
S:=GetTickCount();
for I:=1 to 100000 do
begin
//writeln(IntToStr(i));
end;
E:=GetTickCount();
//writeln(IntToStr(E-S));
K:=K+(E-S);
end; writeln(FloatToStr(K/10));
Readln;
end.
I,L,S,K,E:DWORD;
ddc:THandle;
str:string;
begin
ddc := GetDC(self.Handle);
for L:=1 to 10 do
begin
S:=GetTickCount();
for I:=1 to 100000 do
begin
str:=inttostr(i);
TextOut(ddc,10,40,pansichar(str),length(str));
end;
E:=GetTickCount();
str:=inttostr(e-s);
TextOut(ddc,80,64,pansichar(str),length(str));
K:=K+(E-S);
end;
Label1.Caption:=floatToStr(K/10);
ReleaseDC(self.handle,ddc);
end;确实快 550ms 可惜 Delphi2005VCL.Net 不能使用 Win32 API
I,L,S,K,E:DWORD;
ddc:THandle;
str:string;
begin ddc := GetDC(self.Handle);
for L:=1 to 10 do
begin
S:=GetTickCount();
for I:=1 to 100000 do
begin
str:=inttostr(i);
TextOut(ddc,10,40,(str),length(str));
end;
E:=GetTickCount();
str:=inttostr(e-s);
TextOut(ddc,80,64,(str),length(str));
K:=K+(E-S);
end;
Label1.Caption:=floatToStr(K/10);
ReleaseDC(self.handle,ddc);
end;