I want to get the number of seconds an http request takes. I have this code:
$starttime = microtime(true);
$response = $this->httpClient->request(
'POST',
$endpoint,
[
'headers' => $header,
'body' => $inputXml
]
);
sleep(2);
$endtime = microtime(true);
$timeDiffInSeconds = ($endtime - $starttime);
the request takes around 3 seconds, plus the sleep time, in postman I see 5,08s, that looks correct. But in PHP I $timeDiffInSeconds is float(2.0008609294891).
is http client async?, how can I see the real execution time?.
is there a parameter in the http client that shows the time it took?