Skip to content

Commit

Permalink
Add elapsed time
Browse files Browse the repository at this point in the history
  • Loading branch information
jichangfeng committed Aug 9, 2023
1 parent 0940456 commit 2b31f37
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ array (
'contentType' => 'text/html; charset=UTF-8',
'contentTypeDownload' => 1270.0,
'sizeDownload' => 1270.0,
'elapsedTime' => 1.7826,
'errno' => 0,
'error' => '',
'proxy' => false,
Expand Down
4 changes: 4 additions & 0 deletions src/RequestUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,10 @@ private function request($method, $url) {
}
curl_setopt($curl, constant('CURLOPT_' . $key), $value);
}
$startTime = microtime(true);
$response = curl_exec($curl);
$endTime = microtime(true);
$elapsedTime = round($endTime - $startTime, 4);
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = false;
$body = false;
Expand All @@ -295,6 +298,7 @@ private function request($method, $url) {
'contentType' => curl_getinfo($curl, CURLINFO_CONTENT_TYPE),
'contentTypeDownload' => curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD),
'sizeDownload' => curl_getinfo($curl, CURLINFO_SIZE_DOWNLOAD),
'elapsedTime' => $elapsedTime,
'errno' => curl_errno($curl),
'error' => curl_error($curl),
'proxy' => $this->proxy ? true : false
Expand Down

0 comments on commit 2b31f37

Please sign in to comment.