Profile runtime with Xdebug & webgrind
What is Xdebug?
Xdebug is a debugger and profiler for PHP. We mainly use it as profiler and it’s installed in the Vagrant box by default.
Profiling pages with Xdebug and webgrind
You can profile any page in Vagrant by visiting them and using the
?XDEBUG_PROFILE paramater in the url.
This will generate a new dbkg dump which you can the analyze in your browser using webgrind.
Example: Profile WP admin dashboard
- Visit: http://wordpress.local/wp-admin/?XDEBUG_PROFILE
- Visit http://webgrind.wordpress.local/
- Click update button and wait for webgrind to analyze the dump.
- You can see the profiling of the admin page and look up slow functions which you can then optimize.