In plugin development we create code to add custom functionality into WordPress. This is a powerful feature for WordPress. However if we are not careful we can introduce a performance bottleneck into WordPress.
Luckily we can test the performance of PHP components using Xdebug. However using only Xdebug is not enough, we need a way to visualize it. For this purpose we can use Webgrind to show how the performance of our WordPress and the plugin we develop.
To enable the profiling feature in Xdebug you need to add extra settings to the php.ini
xdebug.profiler_enable = 1
xdebug.profiler_output_name = xdebug.out.%t
xdebug.profiler_output_dir = /tmp
xdebug.profiler_enable_trigger = 1
Restart the local server after the setting addition. Then install the Webgrind. Webgrind is a web application which we can install directly into our local server. However, it is highly discouraged to install it on production server. The installation is straight forward.
- Download Webgrind.
- Extract Webgrind to a folder accessible to the web server.
- Start using Webgrind with your browser of choice by navigating to the URL of your Webgrind install, e.g.