Mar/100
My favorite PHP memory profiler: XHProf
I searched for a PHP memory profiler for a long time. I used xdebug but the memory profiling feature did not work very well and it seems it has been removed in current versions. Then I found the PHP Quick Profiler. But that seemed not to be the best solution for me because I also needed to profile ajax handler scripts which don’t have any GUI to integrate the PQP. But I must admit that I did not give PQP a try. I also tried some self made profiliers similar to the script in this post. But none of the mentioned tools helped me out…
One day I came across XHProf. XHProf has been developed by Facebook and has been released under the Apache License (Version 2.0) in March 2009.
XHProf comes as PHP module and with a webbased GUI for viewing the reports. XHProf can collect function calls and counts inclusive and exclusive metrics such as wall time, CPU time and memory usage. All callers and calles of a function can be browsed in the GUI.
XHProf gives you the ability to render call graphs using the GD Libraries. For example this part of a call graph gives an overview on the current dependencies and the major calls in parts of NagVis 1.5.
It is also possible to show the differences between two calls. This is very useful when doing some performance improvements or call optimizations.
All in all I am happy that I have found that tool. It really helped me to find some bottlenecks and problems in the NagVis 1.5 code.
XHProf can be downloaded from the XHProf PECL page. The documentation is located here.








