find which function(file) causes server overload

谁都会走 提交于 2019-12-10 12:06:31

问题


I have read this topic, but my topic is not duplicate.

It will be excellent, if I had an specific helper function/method, which will track all further functions, which are being executed in PHP, to determine the each function's execution time, like this:

executed URL: /mypage.php
function execution times:
        initialize(): 1.2 seconds
         - cookie_checker(): 0.1 ms
           -- set_cookie():  0.01 ms 
           -- blabla():  0.5 ms
         - start_authorization(): 0.27 ms
        page_output(): 2.4 seconds
         - header_output(): 0.3 ms
           -- XXXXXXXXXXXXX():  0.01 ms 
           -- YYYYYYYYYYYYY():  0.5 ms
         - ZZZZZZZZZZZZZ(): 0.27 ms

so, i will have logs and find out which function causes server/CPU overload. Have you any ideas how to achieve this?


回答1:


As a free tool for profiling php code you can use XHProf. See https://github.com/phacility/xhprof.



来源:https://stackoverflow.com/questions/39216072/find-which-functionfile-causes-server-overload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!