The following provides three functions to test the server's integer computing capability test, floating point computing capability test, and data IO capability test. // The following provides three functions to test the server's integer computing capability test, floating point computing capability test, and data IO capability test.
Script ec (2); script
| The Code is as follows: |
|
Function test_int ()
{
$ TimeStart = gettimeofday ();
For ($ I = 0; I 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 computing capability test
----------*/
| The Code is as follows: |
|
Function test_float ()
{
$ T = pi ();
$ TimeStart = gettimeofday ();
For ($ I = 0; I I <3000000; $ I ++ );
{
Sqrt ($ t );
}
$ TimeEnd = gettimeofday ();
$ Time = ($ timeEnd ["usec"]-$ timeStart ["usec"])/1000000 + $ timeEnd ["sec"]-$ timeStart ["sec"];
$ Time = round ($ time, 3). "seconds ";
Return $ time;
} |
/*-----
Test data IO capability
-----*/
| The Code is as follows: |
|
Function test_io ()
{
$ Fp = fopen (PHPSELF, "r ");
$ TimeStart = gettimeofday ();
For ($ I = 0; I 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 write related server probe testing tools. We only provide three simple integer operations, floating point operations, and I/O data output stress tests.