当前位置:首页 > PHP教程 > php高级应用 > 列表

php检测服务器的运行

发布:smiling 来源: PHP粉丝网  添加日期:2013-12-11 13:13:18 浏览: 评论:0 
  1. // 检测函数支持 
  2. function isfun($funName) { 
  3.  return (false !== function_exists($funName))?'支持':'<font color=red>不支持</font>'
  4. //整数运算能力测试 
  5. function test_int() { 
  6.  $timeStart = gettimeofday(); 
  7.  for($i = 0; $i < 3000000; $i++) { 
  8.   $t = 1+1; 
  9.  } 
  10.  $timeEnd = gettimeofday(); 
  11.  $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"]; 
  12.  $time = round($time, 3)."秒"
  13.  return $time
  14. //浮点运算能力测试 
  15. function test_float() { 
  16.  //得到圆周率值 
  17.  $t = pi(); 
  18.  $timeStart = gettimeofday(); 
  19.  for($i = 0; $i < 3000000; $i++) { 
  20.   //开平方 
  21.   sqrt($t); 
  22.  } 
  23.  $timeEnd = gettimeofday(); 
  24.  $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"]; 
  25.  $time = round($time, 3)."秒"
  26.  return $time
  27. //IO能力测试 
  28. function test_io() { 
  29.  $fp = @fopen(PHPSELF, "r"); 
  30.  $timeStart = gettimeofday(); 
  31.  for($i = 0; $i < 10000; $i++) { 
  32.   @fread($fp, 10240); 
  33.   @rewind($fp); 
  34.  } 
  35.  $timeEnd = gettimeofday(); 
  36.  @fclose($fp); 
  37.  $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"]; 
  38.  $time = round($time, 3)."秒"
  39.  return($time); 

Tags: php检测 服务器 运行

分享到: