$size=1024*50;//这里你可以放大到*足够大*以确保数据能尽可能的接近真实
$callnumber=3;
$ip=$_SERVER[REMOTE_ADDR];
list($useca,$seca)=explode(" ",microtime());
@exec("ping -n $callnumber -l $size $ip",$data) or die("Support Forbid!");
list($usecb,$secb)=explode(" ",microtime());
$sec=$secb-$seca;
$msg=$data[count($data)-3];
list($drop,$info)=explode("(",$msg);
list($info,$drop)=explode("%",$info);
$spead=($size*$callnumber-$size*$callnumber*$info/100)/$sec;
echo sprintf("连接速度%.2f(k/s)",$spead/1024);
?>
文章来源于领测软件测试网 https://www.ltesting.net/