使用php测试硬盘写入速度示例

前端之家收集整理的这篇文章主要介绍了使用php测试硬盘写入速度示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

代码如下:
PHP
set_time_limit(0);
$str = str_pad($str,512,"0");
$file = fopen("./temp","a+");
$i = 0;
$bytes = 1000000000;
$mygabyte = $bytes/1000000;
echo "test start. waiting ...";
$starttime = time();
while($i < $bytes){
$i += fwrite($file,$str);
}

$endtime = time();
$usetime = $endtime - $starttime;
$write_xiaolv = $bytes/$usetime;
$myga_xiaolv = $mygabyte/$usetime;
echo "create 1GB file use time ".$usetime." seconds\n";
echo "speed :".$write_xiaolv." byte/s\n";
echo "speed :".$myga_xiaolv." m/s\n";

猜你在找的PHP相关文章