当前位置:首页 > PHP教程 > 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." secondsn";
echo "speed :".$write_xiaolv." byte/sn";
echo "speed :".$myga_xiaolv." m/sn";


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!