WordPress Plugin Performance: Profiling using Xdebug and Webgrind

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.

  1. Download Webgrind.
  2. Extract Webgrind to a folder accessible to the web server.
  3. Start using Webgrind with your browser of choice by navigating to the URL of your Webgrind install, e.g. http://localhost/webgrind.


Webgrind Installation