Skip to content

Instantly share code, notes, and snippets.

@levonlee
Created July 16, 2014 14:25
Show Gist options
  • Save levonlee/8e8e45e2411503b4e084 to your computer and use it in GitHub Desktop.
Save levonlee/8e8e45e2411503b4e084 to your computer and use it in GitHub Desktop.
PHP Test Website Connection
$loop = 20; // Number of times to connect to website
$url = "http://www.yoursite.com/";
$start = microtime(true);
for ($i=1; $i < $loop; $i++) {
$lstart = microtime(true);
$f = fopen($url, 'r', 0);
$meta_data =stream_get_meta_data($f)['wrapper_data'][0];
fclose($f);
$ltime = microtime(true) - $lstart;
echo $i.": ".$meta_data.' time: '.$ltime.'<br/>';
}
$ttime = microtime(true) - $start;
echo 'Total time: '. $ttime;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment