php测试判断网络速度源码

  1. <?php
  2. $kb=10240;
  3. echo "streaming $kb Kb...<!-";
  4. flush();
  5. $time = explode(" ",microtime());
  6. $start = $time[0] + $time[1];
  7. for($x=0;$x<$kb;$x++){
  8.     echo str_pad('', 1024, '.');
  9.     flush();
  10. }
  11. $time = explode(" ",microtime());
  12. $finish = $time[0] + $time[1];
  13. $deltat = $finish - $start;
  14. echo "-> Test finished in $deltat seconds. Your speed is ". round($kb / $deltat, 3)."Kb/s";
  15. ?>

发布日期:

所属分类: Php 标签: