我发布并收到了cURL的回复。无论如何,我可以记录发送到收到回复的时间吗?这是我的帖子和回复代码的样子。
$ch = curl_init($Url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataBeingPassed);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
答案 0 :(得分:0)
curl_getinfo ( resource $ch [, int $opt = 0 ] )
答案 1 :(得分:0)
您可以在请求之前保存时间,并将其与请求后的时间进行比较 -
$start_ts = time();
// code that takes some time goes here
echo "This code took" . (time() - $start_ts) .' seconds to execute";
使用此方法,您只能以秒为单位测量急性。 time()
函数返回epoch timestamp(自1970年1月1日起的秒数)。
对于一些更准确的测量,您可能需要查看PHP的microtime()
function。
答案 2 :(得分:0)
您可能想尝试curl_getinfo。
CURLINFO_TOTAL_TIME - Total transaction time in seconds for last transfer
CURLINFO_NAMELOOKUP_TIME - Time in seconds until name resolving was complete
CURLINFO_CONNECT_TIME - Time in seconds it took to establish the connection
CURLINFO_PRETRANSFER_TIME - Time in seconds from start until just before file transfer begins
CURLINFO_STARTTRANSFER_TIME - Time in seconds until the first byte is about to be transferred
答案 3 :(得分:0)
您可以使用curl_getinfo()。 请参阅此