2011-05-24 71 views
-1

我使用PHP和Zend。我的一些代碼花費了太多時間來執行。知道特定函數/構造函數消耗多少時間的最佳方法是什麼?如何知道特定功能的運行時間?

例如:

我打電話這樣的功能:

$insuranceModel = new Model_Insurance_Object(); 
$insurances = $insuranceModel->getInsurancesList(); 

getInsurancesList功能Model_Insurance_Object

public function getInsurancesList() { 
    // function body 
} 

我應該落實在哪裏我是不是該地點?

感謝

+0

的[剖析PHP腳本最簡單的方法]可能重複(http://stackoverflow.com/questions/21133/simplest-way-to-profile-a-php-script) – Gordon 2011-05-24 08:26:15

回答

5

XDebugProfiler。看來,這正是你正在尋找的。

+0

也[kcachegrind] (http://kcachegrind.sourceforge.net/html/Home.html)非常有用 – martynthewolf 2011-05-24 08:06:22

1

@KingChurch很好的回答! :D如果您不想使用.dll安裝路徑,您還可以編寫一段代碼長度爲運行時間的benchit()

function benchit() 
{ 
    list($msec, $sec) = explode(' ', microtime()); 
    return (double)$sec + (double)$msec; 
} 

$start = benchit(); 
// ... Some code here 
$end = benchit(); 
相關問題