PHP server integer, floating-point, data IO capability test function

Source: Internet
Author: User
Tags php server
  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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.