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

[code]
xdebug.profiler_enable = 1

xdebug.profiler_output_name = xdebug.out.%t

xdebug.profiler_output_dir = /tmp

xdebug.profiler_enable_trigger = 1
[/code]

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.

 

Reference:

Webgrind Installation

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.