XHProf is a profiler that can measure processing time for each function called to render a page.
Installation on lando
.lando.yml
services:
config:
php: config/php.ini
appserver:
build_as_root:
- apt update
- apt install -y graphviz
- pecl install xhprof
- docker-php-ext-enable /usr/local/lib/php/extensions/no-debug-non-zts-20210902/xhprof.so
For info on the docker-php-ext-enable command, see https://hub.docker.com/_/php/.
config/php.ini
xhprof.output_dir = /app/xhprof
XHProf module
https://www.drupal.org/project/xhprof
Install, enable and configure xhprof as the profiler.
View reports.
Callgraph
View the function call graph, rendered with graphviz.
This patch is needed: https://www.drupal.org/project/xhprof/issues/1470740#comment-14385462
Since Drupal can go through many php files, the callgraph is often too big to comprehend.
Activate the profiler manually, around the code you want to profile.
xhprof_enable();
test_function();
$data = xhprof_disable();
file_put_contents('/app/xhprof/output.html', $data);
PHP Profiler module
https://www.drupal.org/project/php_profiler
TODO.
Modules
Resources