当前位置:Linux教程 - Php - 显示页面运行时间的代码3个

显示页面运行时间的代码3个

[php]显示页面运行时间的代码<3个>

作者:--  时间:2004-05-02 21:42:37  来自:落伍  责任编辑:clinch







$gentime = microtime();
$gentime = explode(' ',$gentime);
$gentime = $gentime[1] + $gentime[0];
$pg_start = $gentime;

?>

$gentime = microtime();
$gentime = explode(' ',$gentime);
$gentime = $gentime[1] + $gentime[0];
$pg_end = $gentime;
$totaltime = ($pg_end - $pg_start);
$showtime = number_format($totaltime, 4, '.', '');
echo("本页面运行时间" . $showtime . " 秒");

?>



$time_start=explode(" ",microtime());


……

$time_end=explode(" ",microtime());
$c=$time_end[0]+$time_end[1]-$time_start[0]-$time_start[1];
echo "

运行时间:".$c."秒
";
?>




ipb的类
class Debug {
    function startTimer() {
        global $starttime;
        $mtime = microtime ();
        $mtime = explode (' ', $mtime);
        $mtime = $mtime[1] + $mtime[0];
        $starttime = $mtime;
    }
    function endTimer() {
        global $starttime;
        $mtime = microtime ();
        $mtime = explode (' ', $mtime);
        $mtime = $mtime[1] + $mtime[0];
        $endtime = $mtime;
        $totaltime = round (($endtime - $starttime), 5);
        return $totaltime;
    }
}