php 测试网速

// $res = file_get_contents('1.log');

// class b{
//     function json_decode(){
//         echo '132';

//     }
// }

// $b = new b;
// $b->json_decode();
$kb=10240;

echo "streaming $kb Kb...

flush(); //刷新输出缓冲

$time = explode(" ",microtime());

$start = $time[0] + $time[1];

for($x=0;$x<$kb;$x++){

    echo str_pad('', 1024, '.');

    flush();

}

$time = explode(" ",microtime());

$finish = $time[0] + $time[1];

$deltat = $finish - $start;

echo "-> Test finished in $deltat seconds. Your speed is ". round($kb / $deltat, 3)."Kb/s";

转载于:https://my.oschina.net/u/2005502/blog/825712

你可能感兴趣的:(php 测试网速)