例1,, 復(fù)制代碼代碼示例: <!--<?php //這里是網(wǎng)頁 例2, 復(fù)制代碼代碼示例: <? $pagestartime=microtime(); ?> <!--網(wǎng)頁內(nèi)容 start--> 網(wǎng)頁內(nèi)容 ... ... <!--網(wǎng)頁內(nèi)容 end--> <? $pageendtime = microtime(); $starttime = explode()(" ",$pagestartime); $endtime = explode(" ",$pageendtime); $totaltime = $endtime[0]-$starttime[0]+$endtime[1]-$starttime[1]; $timecost = sprintf()("%s",$totaltime); echo "頁面運(yùn)行時(shí)間: $timecost 秒"; //by www. ?> 例3,, 復(fù)制代碼代碼示例: <? //計(jì)算頁面執(zhí)行時(shí)間 $time_start = getmicrotime(); function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } ?> 然后,,在頁面結(jié)尾加入: 復(fù)制代碼代碼示例: <?
$time_end = getmicrotime(); printf ("[頁面執(zhí)行時(shí)間: %.2f毫秒]\n\n",($time_end - $time_start)*1000); //統(tǒng)計(jì)出當(dāng)前頁的執(zhí)行時(shí)間 ?> |
|