Php testing server running capability _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Php detects the running capability of the server. Php detection server running ability detection function supports functionisfun ($ funName) {return (false! Function_exists ($ funName ))? Supported: fontcolorred does not support font;} integer php testing server running capability

// Detection function support
Function isfun ($ funName ){
Return (false! = Function_exists ($ funName ))? 'Supported ': 'unsupported ';
}

// Integer computing capability test
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
Function test_float (){
// Obtain the circumference rate
$ T = pi ();
$ TimeStart = gettimeofday ();
For ($ I = 0; I I <3000000; $ I ++ ){
// Square
Sqrt ($ t );
}
$ TimeEnd = gettimeofday ();
$ Time = ($ timeEnd ["usec"]-$ timeStart ["usec"])/1000000 + $ timeEnd ["sec"]-$ timeStart ["sec"];
$ Time = round ($ time, 3). "seconds ";
Return $ time;
}

// IO capability test
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 );
}

FUNCTIONS // detection functions support function isfun ($ funName) {return (false! = Function_exists ($ funName ))? 'Supported ': 'Font color = red does not support/font';} // integer operation...

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.