PHP Kod: Kodu kopyalamak için üzerine çift tıklayın!
<?php
if($_GET['do'] == '')
{
echo "<b><a href='?do=test&size=100'>Speed test with 100KB</a></b><br>";
echo "<b><a href='?do=test&size=512'>Speed test with 512KB</a></b><br>";
echo "<b><a href='?do=test&size=1024'>Speed test with 1024KB</a></b><br>";
echo "<b><a href='?do=test&size=5000'>Speed test with 5000KB</a></b><br>";
}
if($_GET['do'] == 'test')
{
$_size = $_GET['size'];
if(($_size == '100') || ($_size == '512') || ($_size == '1024') || ($_size == '5000'))
{
$numKB = $_size*1024;
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
flush();
$timeStart = getmicrotime();
$nlLength = strlen("<br>");
for ($i = 0; $i < $numKB; $i++)
{
$string = str_pad('', 1024 - $nlLength, '/*\\*') . "<br>";
flush();
}
$timeEnd = getmicrotime();
$timeDiff = round($timeEnd - $timeStart, 1);
echo "<br><b>Transferred " . $numKB/1024 . " <abbr title=\"kilobyte\">KB</abbr> in {$timeDiff} seconds. <a href='?do='>Test Again</a></b><br>";
}
else
{
echo "<b>Sorry, please pick a valid size.</b><a href='?do='>Geri Dön</a><br>";
}
?>