PHP Profiling – XHProf

XHProf is a heriarcical profiler for PHP originally developed by Facebook and then opensourced. The raw data collection component is implemented in C (as a PHP extension). The reporting/UI layer is all in PHP. It is capable of reporting function-level inclusive and exclusive wall times, memory usage, CPU times and number of calls for each function. Additionally, it supports ability to compare two runs (hierarchical DIFF reports), or aggregate results from multiple runs.
Here are some of the reports that XHProf provides:
- Flat profile (screenshot)
- Hierarchical profile (Parent/Child View) (screenshot)
- Diff Reports : The “flat” view (sample screenshot) & “hierarchical” (or parent/child) diff view of a function (sample screenshot).
- Callgraph View (sample screenshot)
- Memory Profile : XHProf’s memory profile mode helps track functions that allocate lots of memory.
If you are looking for an article which gives you details on how to install this extension in Ubuntu and a quick runthrough of how to use this, Lorenzo Alberton has an excellent article on this at Profiling with XHProf. There’s also a good background article on XHProf and why Facebook developed this extension over at Facebook.
Links:
XHProf Documentation
XHProf on PECL
Profiling with XHProf
Image Credit: from Crestock Photos

![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=1b3847a0-9cc8-4728-bf0d-68b8bf9d5d33)

