by idoubtit · 4y ago · 0 comments
My preferred tool is php-spx. Once the extension is loaded into PHP, within seconds you get a flamegraph of where time is spent. It's also easy to apply to command-line scripts. And it's versatile enough (with the right settings) to profile long-running or memory heavy scripts. https://github.com/NoiseByNorthwest/php-spx
SPX could be loaded with docker-compose like this article does for Xdebug. But if you already have a PHP environment, the easiest way to install it is to compile it (sudo apt install php-dev && make && cp modules/spx.so /usr/lib/php/....).
I've tried using xdebug for profiling, but as you say it is just not up to the task. Even leaving the extension enabled without any tracing or debug session enabled wreaks havoc on the performance characteristics.