I am trying to develop a basic PHP tool to record the response times of a website, when using HTTP and HTTPS.
Overall, I wish to record several times and then compare them. To give an overview of the difference of speed between HTTP & HTTPS.
I am using CURL, I have made this so far:
<?php
// curl handle
$ch = curl_init($_GET['x']); // ?x= url target
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); // fresh connection, don't cache
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_CERTINFO, 1); // enables SSL ?
// execute / load website
curl_exec($ch);
// check for error
if(!curl_errno($ch))
{
$c = curl_getinfo($ch);
echo 'Sending request to: ' . $c['url'].' <br />
Connect time: '.$c['connect_time'].'<br />
Name Lookup time: '.$c['namelookup_time'].'<br />
Pre transfer time: '.$c['pretransfer_time'].'<br />
Header size: '.$c['header_size'].'<br />
Average download speed: '.$c['speed_download'].'<br />
Took <b>'.$c['total_time'].'</b> seconds in total';
}
// close curl
curl_close($ch);
?>
Does anyone know if CURL does indeed take into account the HTTPS headers and additional procedures it completes (e.g. handshake phase) when establishing a connection?
I think I have set the CURL options correctly, I have ran several tests, they seem to differ. But I need to know if CURL is accurate for this sort of testing, or would you recommend something else?
HTTP: http://www.isomerizer.com/curl.php?x=http://www.google.com
HTTPS: http://www.isomerizer.com/curl.php?x=https://www.google.com
Also, would my webserver hosting the PHP make a difference?