Rumah  >  Artikel  >  php教程  >  php检测服务器的运行

php检测服务器的运行

WBOY
WBOYasal
2016-05-25 16:51:381428semak imbas

<?php
// 检测函数支持
function isfun($funName) {
    return (false !== function_exists($funName)) ? &#39;支持&#39; : &#39;<font color=red>不支持</font>&#39;;
}
//整数运算能力测试
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) . "秒";
    return $time;
}
//浮点运算能力测试
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) . "秒";
    return $time;
}
//IO能力测试
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) . "秒";
    return ($time);
}


教程地址:

欢迎转载!但请带上文章地址^^

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn