Home > php教程 > php手册 > body text

模拟测试连接速度

WBOY
Release: 2016-06-21 09:11:56
Original
1168 people have browsed it

速度

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



Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template