怎么编译出快速的程序
如何编译出快速的程序
var
G: double ;
TT: Longint ;
begin
TT := GetTickCount;
G:=1;
for i := 1 to 10000000 do begin
G := G * 0.999;
end;
edit2.Text := FormatFloat('0.00',GetTickCount -TT ) ;
end;
1000 万转 = 2 秒 ( 使用 Run -> Run Without Debugging )
同样的 Code 用 VB6 1000 万转 = 0.018 秒
delphi 不可能这么慢啊
我要如何编译才能加快呢 (如何设定编译选项呢)
------解决思路----------------------
1. 开优化,{$O+} {$D-} {$L-}
2. 不要在IDE里运行,编译成exe后单独运行这个exe.。
2秒得多慢哪,你的什么电脑?不会是中毒了吧。我用农企的廉价APU电脑测试,0.015秒,显然是GetTickCount的精度不够了,改用QueryPerformancePfrquency、QueryPerformanceCounter计时间,0.005秒。没有VB,所以无法对比。
var
G: double ;
TT: Longint ;
begin
TT := GetTickCount;
G:=1;
for i := 1 to 10000000 do begin
G := G * 0.999;
end;
edit2.Text := FormatFloat('0.00',GetTickCount -TT ) ;
end;
1000 万转 = 2 秒 ( 使用 Run -> Run Without Debugging )
同样的 Code 用 VB6 1000 万转 = 0.018 秒
delphi 不可能这么慢啊
我要如何编译才能加快呢 (如何设定编译选项呢)
------解决思路----------------------
1. 开优化,{$O+} {$D-} {$L-}
2. 不要在IDE里运行,编译成exe后单独运行这个exe.。
2秒得多慢哪,你的什么电脑?不会是中毒了吧。我用农企的廉价APU电脑测试,0.015秒,显然是GetTickCount的精度不够了,改用QueryPerformancePfrquency、QueryPerformanceCounter计时间,0.005秒。没有VB,所以无法对比。