Home >Backend Development >PHP Tutorial >PHP detects the running ability of the server_PHP tutorial

PHP detects the running ability of the server_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:58:13924browse

php detects the server’s operating capabilities

//Detection function support
function isfun($funName) {
return (false !== function_exists($funName))?'Supported':'Not supported';
}

//Integer operation ability test
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 computing capability test
function test_float() {
//Get the pi value
$t = pi();
$timeStart = gettimeofday();
for($i = 0; $i < 3000000; $i++) {
//Square root
sqrt($t);
}
$timeEnd = gettimeofday();
$time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
$time = round($time, 3)."seconds";
return $time;
}

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632010.htmlTechArticlephp detects the running ability of the server // The detection function supports function isfun($funName) { return (false !== function_exists($funName))?'Support':'font color=red does not support /font'; } //Integer operation...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn