Created
July 24, 2015 10:08
-
-
Save fntlnz/be951a4d32a14ed68a9d to your computer and use it in GitHub Desktop.
php dns check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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