Profiling with XHProf
suggest changeXHProf is a PHP profiler originally written by Facebook, to provide a more lightweight alternative to XDebug.
After installing the xhprof PHP module, profiling can be enabled / disabled from PHP code:
xhprof_enable();
doSlowOperation();
$profile_data = xhprof_disable();
The returned array will contain data about the number of calls, CPU time and memory usage of each function that has been accessed inside doSlowOperation().
xhprof_sample_enable() / xhprof_sample_disable() are a lighter sampling mode. They record a sample of the call stack at intervals during the request, in a different format, rather than a fraction of requests.
XHProf has some (mostly undocumented) helper functions to display the data (see example), or you can use other tools to visualize it (the platform.sh blog has an example).
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents