code is as follows |
copy code |
function Test_int () { $timeStart = Gettimeofday (); for ($i = 0; $i < 3000000; $i + +); { $t = 1+1; } $timeEnd = Gettimeofday (); $time = ($timeEnd ["USEC"]-$timeStart ["USEC"])/1000000+ $timeEnd [sec]]-$timeStart [sec]; $time = Round ($time, 3). " Seconds "; return $time; }
|
/*--------
Floating point arithmetic capability test
----------*/
code is as follows |
copy code |
function test_float () { $t = Pi (); $timeStart = Gettimeofday (); for ($i = 0; $i < 3000000; $i + +); { sqrt ($t); } $timeEnd = Gettimeofday (); $time = ($timeEnd ["USEC"]-$timeStart ["USEC"])/1000000+ $timeEnd [" SEC "]-$timeStart [sec]; $time = Round ($time, 3). " Seconds "; return $time; } |
/*-----
Data IO capability test
-----*/
The code is as follows |
Copy Code |
function Test_io () { $fp = fopen (phpself, "R"); $timeStart = Gettimeofday (); for ($i = 0; $i < 10000; $i + +) { Fread ($fp, 10240); Rewind ($FP); } $timeEnd = Gettimeofday (); Fclose ($FP); $time = ($timeEnd ["USEC"]-$timeStart ["USEC"])/1000000+ $timeEnd [sec]]-$timeStart [sec]; $time = Round ($time, 3). " Seconds "; return ($time); } |
/*
Many companies have written their own relevant server probe testing tools, we provide you with just three kinds of simple integer operations, floating-point operations, and IO data output pressure test.