问题
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