简体   繁体   English

如何使用TIdTCPClient或其他Indy客户端组件从网站计算响应时间?

[英]How to calculate response time from website using TIdTCPClient or another Indy client component?

I have an application that sends and receives data from a given website with TIdTCPClient - looks like this : 我有一个使用TIdTCPClient从给定网站发送和接收数据的应用程序-看起来像这样:

TCPClient.Host := myHost;
TCPClient.Port := myPort;
TCPClient.Connect;
TCPClient.IOHandler.Write(clientRequest);
TCPClient.IOHandler.ReadStream(clientResponse, size, False);

where clientRequest is created dynamically and clientResponse is what the server (the wanted website) sends as a response.So my question is how can I calculate the average response time from the website my TCPClient has connected to ? 这里动态创建了clientRequestclientResponse是服务器(想要的网站)作为响应发送的内容。所以我的问题是如何从我的TCPClient连接到的网站计算平均响应时间?

Look at Indy's Ticks() and GetTickDiff() functions, for example: 查看Indy的Ticks()GetTickDiff()函数,例如:

uses
  ..., IdGlobal;

var
  StartTicks: LongWord;
begin
  ...
  StartTicks := Ticks;
  TCPClient.IOHandler.ReadStream(clientResponse, size, False);
  Elapsed := GetTickDiff(StartTicks, Ticks);
  ...
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM