Home >php教程 >PHP源码 >php测试硬盘写速率

php测试硬盘写速率

PHP中文网
PHP中文网Original
2016-05-25 17:00:071041browse

使用php写入一个1GB大小的文件,检查硬盘的写速率,可能有一定误差,

建议还是使用专业的硬盘测试工具来检测

一般电脑读写在20M/s,这个测试要执行大概40-50s

1. [代码][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";

2. [图片] QQ截图20140126093610.png       


php测试硬盘写速率

                                           

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