模拟测试连接速度
发表于:2007-07-01来源:作者:点击数:
标签:
<?
php
$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);
?>
原文转自:http://www.ltesting.net