您现在的位置: 万盛学电脑网 >> 电脑基础 >> 电脑基本常识 >> 正文

怎么测试硬盘写速率?分析一下php测试硬盘写速率

作者:佚名    责任编辑:admin    更新时间:    2015-10-19 17:39:08

class="area"> 怎么测试硬盘写速率?分析一下php测试硬盘写速率,今天电脑知识吧的小编,具体如下,

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

<?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";