Home >php教程 >php手册 >模拟测试连接速度

模拟测试连接速度

WBOY
WBOYOriginal
2016-06-21 09:11:561204browse

速度

$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);
?>



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn