2014-11-04 26 views
0

假設我在生產服務器上有一個應用程序,我需要對代碼段進行概要分析,但不是整個應用程序,因爲它會大幅降低速度。如何在php中剖析concreate函數或代碼段?

所以我需要的東西是這樣的:

enable_profiler();
function_with_bottle_neck();
disable_profiler();

有沒有辦法做到這一點?

回答

1

使用xhprof。你可以寫這樣的東西:

if ($_SERVER['REMOTE_ADDR'] == 'your_ip') { 
enable_profiler(); 
} 
function_with_bottle_neck(); 

if ($_SERVER['REMOTE_ADDR'] == 'your_ip') { 
disable_profiler(); 
}