Php test hard disk write rate. Use php to write a 1 GB file, check the hard disk write rate, there may be some errors, it is recommended to use a professional hard disk testing tool to detect general computer read and write in 20 Ms, this is a 1 GB file written in php. check the hard disk write rate, which may have some errors,
We recommend that you use professional hard disk testing tools for testing.
Generally, the computer reads and writes at 20 Mb/s. this test takes about 40-50 s.
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 1 GB file use time". $ usetime. "seconds \ n ";
Echo "speed:". $ write_xiaolv. "byte/s \ n ";
Echo "speed:". $ myga_xiaolv. "m/s \ n ";
Refer, it is recommended to use professional hard disk testing tools to detect the average computer read and write at 20 MB/s, this...