我发现在为TIdHTTP组件设置ConnectTimeoout属性时,它会使请求(GET和POST)变得慢约120ms?
为什么会这样,我可以以某种方式避免/绕过这个吗?
环境:D2010发布的Indy组件,为D2010安装了所有更新.操作系统是WinXP(32位)SP3,大多数补丁......
我的计时程序是:
Procedure DoGet;
Var
Freq,T1,T2 : Int64;
Cli : TIdHTTP;
S : String;
begin
QueryPerformanceFrequency(Freq);
Try
QueryPerformanceCounter(T1);
Cli := TIdHTTP.Create( NIL );
Cli.ConnectTimeout := 1000; // without this we get < 15ms!!
S := Cli.Get('http://127.0.0.1/empty_page.php');
Finally
FreeAndNil(Cli);
QueryPerformanceCounter(T2);
End;
Memo1.Lines.Add('Time = '+FormatFloat('0.000',(T2-T1)/Freq) );
End;
Run Code Online (Sandbox Code Playgroud)
在代码中设置ConnectTimeout,我得到了平均值.130-140ms的时间,没有它约5-15ms ......