Skip to content

Instantly share code, notes, and snippets.

@fntlnz
Created July 24, 2015 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fntlnz/be951a4d32a14ed68a9d to your computer and use it in GitHub Desktop.
Save fntlnz/be951a4d32a14ed68a9d to your computer and use it in GitHub Desktop.
php dns check
<?php
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$i = 0;
$maxTime = 0;
while (true) {
$time_start = microtime_float();
echo $i . PHP_EOL;
$rec = dns_get_record("facebook.com");
var_dump($rec);
$i++;
$time_end = microtime_float();
if (!isset($rec[0]['host'])) {
break;
}
$currentTime = $time_end - $time_start;
echo sprintf('Total time: %f %s', $currentTime, PHP_EOL);
if ($currentTime > $maxTime) {
$maxTime = $currentTime;
echo "Max time regression here!" . PHP_EOL;
sleep(10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment