Skip to content

Instantly share code, notes, and snippets.

@kian
Last active March 2, 2017 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kian/cb4ea2c7dbd3a1c1147f435b820078b4 to your computer and use it in GitHub Desktop.
Save kian/cb4ea2c7dbd3a1c1147f435b820078b4 to your computer and use it in GitHub Desktop.

Profiling with Xdebug/Webgrind

One of the important steps in improving application performance is profiling. Xdebug produces information for each request. Webgrind is a web interface which ingests this data for analysis.

Setup

The Xdebug extension is already installed for you. On production, it can be enabled as needed.

  1. Open public_html/.htaccess
  2. Set xdebug.profiler_enable to 1 and save. Alternatively, edit the next line instead to profile select requests.

If you want to profile "API" requests (e.g., public_api/api_modules/* functions), do the same for public_api/.htaccess

Install Webgrind

Clone webgrind into public_html/tools/.

$ git clone https://github.com/jokkedk/webgrind public_html/tools/webgrind

Profile

Use the application. Then, visit http://www.placelocal-dev.com/tools/webgrind/.

Select a cachegrind output file (corresponding to HTTP request) within the top-right dropdown and hit "Update". Below you will see a breakdown of which function calls were the most expensive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment