Heim >Backend-Entwicklung >PHP-Tutorial >php检测服务器的运行能力_PHP教程

php检测服务器的运行能力_PHP教程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:58:13913Durchsuche

php检测服务器的运行能力

// 检测函数支持
function isfun($funName) {
 return (false !== function_exists($funName))?'支持':'不支持';
}

//整数运算能力测试
function test_int() {
 $timeStart = gettimeofday();
 for($i = 0; $i   $t = 1+1;
 }
 $timeEnd = gettimeofday();
 $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
 $time = round($time, 3)."秒";
 return $time;
}

//浮点运算能力测试
function test_float() {
 //得到圆周率值
 $t = pi();
 $timeStart = gettimeofday();
 for($i = 0; $i   //开平方
  sqrt($t);
 }
 $timeEnd = gettimeofday();
 $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
 $time = round($time, 3)."秒";
 return $time;
}

//IO能力测试
function test_io() {
 $fp = @fopen(PHPSELF, "r");
 $timeStart = gettimeofday();
 for($i = 0; $i   @fread($fp, 10240);
  @rewind($fp);
 }
 $timeEnd = gettimeofday();
 @fclose($fp);
 $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
 $time = round($time, 3)."秒";
 return($time);
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/632010.htmlTechArticlephp检测服务器的运行能力 // 检测函数支持 function isfun($funName) { return (false !== function_exists($funName))?'支持':'font color=red不支持/font'; } //整数运...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn