国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

php測試程序運(yùn)行速度和頁面執(zhí)行速度的代碼

瀏覽:34日期:2022-06-06 13:05:01

microtime() 函數(shù)返回當(dāng)前 Unix 時間戳的微秒數(shù)。用于檢測程序執(zhí)行時間的函數(shù),也是PHP內(nèi)置的時間函數(shù)之一,在PHP中可以用于對程序執(zhí)行時間的判斷,以及相同功能函數(shù)的執(zhí)行效率高低快慢的判斷。

使用microtime() 函數(shù)測試程序運(yùn)行速度和頁面執(zhí)行速度的代碼如下:

 <?php
class timer {    
var $StartTime = 0;    
var $StopTime = 0;    
var $TimeSpent = 0;    
function start(){    
$this->StartTime = microtime();    
}    
 
function stop(){    
$this->StopTime = microtime();    
}    
 
function spent() {    
if ($this->TimeSpent) {    
return $this->TimeSpent;    
} else {    
$StartMicro = substr($this->StartTime,0,10);    
$StartSecond = substr($this->StartTime,11,10);    
$StopMicro = substr($this->StopTime,0,10);    
$StopSecond = substr($this->StopTime,11,10);    
$start = floatval($StartMicro) + $StartSecond;    
$stop = floatval($StopMicro) + $StopSecond;    
$this->TimeSpent = $stop - $start;    
return round($this->TimeSpent,8)."秒";    
}  
} // end function spent();    
 
} //end class timer;  
 
//$timer = new timer;//實例化測試類  
//$timer->start();//放在代碼開始執(zhí)行的測試點(diǎn)

//$timer->stop();   //放在代碼執(zhí)行結(jié)束的測試點(diǎn)
//print_r("</br>運(yùn)行時間為: ".$timer->spent()) ;
//unset($timer); 

到此這篇關(guān)于php測試程序運(yùn)行速度和頁面執(zhí)行速度的代碼的文章就介紹到這了,更多相關(guān)php測試執(zhí)行速度代碼內(nèi)容請搜索以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持!

標(biāo)簽: PHP
主站蜘蛛池模板: 黄石市| 浪卡子县| 呼和浩特市| 抚顺市| 孟州市| 达州市| 淄博市| 永济市| 庆阳市| 东兴市| 图们市| 固安县| 兖州市| 锦州市| 郁南县| 吴忠市| 呼和浩特市| 蓬安县| 时尚| 牙克石市| 大同县| 巍山| 奎屯市| 绥阳县| 贞丰县| 宁津县| 高清| 巴彦县| 酉阳| 盱眙县| 清远市| 呼图壁县| 梧州市| 资源县| 绍兴市| 宁国市| 中牟县| 中阳县| 芜湖县| 青州市| 青龙|