Quickly identify what's slow with WordPress
Find a file
Daniel Bachhuber 641424344f Merge pull request #122 from runcommand/ignore-distribution-files
Generally ignore distribution files
2016-11-03 07:28:19 -07:00
bin Profiles _responses_, not the requests themselves 2016-11-03 06:57:32 -07:00
features Drop execution time from cache test 2016-11-03 06:21:17 -07:00
inc Add an inline example for wp profile stage 2016-11-03 07:18:24 -07:00
utils Initial commit 2016-07-25 07:36:55 -07:00
.distignore Generally ignore distribution files 2016-11-03 05:05:05 -07:00
.editorconfig Initial commit 2016-07-25 07:36:55 -07:00
.gitignore Generally ignore distribution files 2016-11-03 05:05:05 -07:00
circle.yml Set timezone in CircleCI to prevent random build failures 2016-10-19 06:11:14 -07:00
command.php Abstract profiler to a dedicated class 2016-10-08 06:37:41 -07:00
composer.json Add a v0.3.0 shield 2016-11-03 07:00:07 -07:00
LICENSE.md Add license to the project root 2016-10-31 06:11:24 -07:00
README.md Add an inline example for wp profile stage 2016-11-03 07:18:24 -07:00
wp-cli.yml Initial commit 2016-07-25 07:36:55 -07:00

runcommand/profile

Quickly identify what's slow with WordPress.

runcommand premium version 0.3.0 CircleCI

Quick links: Overview | Using | Installing | Support

Overview

wp profile monitors key performance indicators of the WordPress execution process to help you quickly identify points of slowness.

Save hours diagnosing slow WordPress sites. Because you can easily run it on any server that supports WP-CLI, wp profile compliments Xdebug and New Relic by pointing you in the right direction for further debugging. Because runs on the command line, using wp profile means you don't have to install a plugin and deal with the painful dashboard of a slow WordPress site. And, because it's a WP-CLI command, wp profile makes it easy to perfom hard tasks (e.g. profiling a WP REST API response).

Identify why WordPress is slow in just a few steps with wp profile.

Using

This package implements the following commands:

wp profile stage

Profile each stage of the WordPress load process (bootstrap, main_query, template).

wp profile stage [<stage>] [--all] [--spotlight] [--url=<url>] [--fields=<fields>] [--format=<format>]

When WordPress handles a request from a browser, its essentially executing as one long PHP script. wp profile stage breaks the script into three stages:

  • bootstrap is where WordPress is setting itself up, loading plugins and the main theme, and firing the init hook.
  • main_query is how WordPress transforms the request (e.g. /2016/10/21/moms-birthday/) into the primary WP_Query.
  • template is where WordPress determines which theme template to render based on the main query, and renders it.
# `wp profile stage` gives an overview of each stage.
$ wp profile stage --fields=stage,time,cache_ratio
+------------+---------+-------------+
| stage      | time    | cache_ratio |
+------------+---------+-------------+
| bootstrap  | 0.7994s | 93.21%      |
| main_query | 0.0123s | 94.29%      |
| template   | 0.792s  | 91.23%      |
+------------+---------+-------------+
| total (3)  | 1.6037s | 92.91%      |
+------------+---------+-------------+

# Then, dive into hooks for each stage with `wp profile stage <stage>`
$ wp profile stage bootstrap --fields=hook,time,cache_ratio --spotlight
+--------------------------+---------+-------------+
| hook                     | time    | cache_ratio |
+--------------------------+---------+-------------+
| muplugins_loaded:before  | 0.2335s | 40%         |
| muplugins_loaded         | 0.0007s | 50%         |
| plugins_loaded:before    | 0.2792s | 77.63%      |
| plugins_loaded           | 0.1502s | 100%        |
| after_setup_theme:before | 0.068s  | 100%        |
| init                     | 0.2643s | 96.88%      |
| wp_loaded:after          | 0.0377s |             |
+--------------------------+---------+-------------+
| total (7)                | 1.0335s | 77.42%      |
+--------------------------+---------+-------------+

OPTIONS

[<stage>]
	Drill down into a specific stage.

[--all]
	Expand upon all stages.

[--spotlight]
	Filter out logs with zero-ish values from the set.

[--url=<url>]
	Execute a request against a specified URL. Defaults to the home URL.

[--fields=<fields>]
	Limit the output to specific fields. Default is all fields.

[--format=<format>]
	Render output in a particular format.
	---
	default: table
	options:
	  - table
	  - json
	  - yaml
	  - csv
	---

wp profile hook

Profile key metrics for WordPress hooks (actions and filters).

wp profile hook [<hook>] [--all] [--spotlight] [--url=<url>] [--fields=<fields>] [--format=<format>]

In order to profile callbacks on a specific hook, the action or filter will need to execute during the course of the request.

OPTIONS

[<hook>]
	Drill into key metrics of callbacks on a specific WordPress hook.

[--all]
	Profile callbacks for all WordPress hooks.

[--spotlight]
	Filter out logs with zero-ish values from the set.

[--url=<url>]
	Execute a request against a specified URL. Defaults to the home URL.

[--fields=<fields>]
	Display one or more fields.

[--format=<format>]
	Render output in a particular format.
	---
	default: table
	options:
	  - table
	  - json
	  - yaml
	  - csv
	---

wp profile eval

Profile arbitrary code execution.

wp profile eval <php-code> [--fields=<fields>] [--format=<format>]

Code execution happens after WordPress has loaded entirely, which means you can use any utilities defined in WordPress, active plugins, or the current theme.

OPTIONS

<php-code>
	The code to execute, as a string.

[--fields=<fields>]
	Display one or more fields.

[--format=<format>]
	Render output in a particular format.
	---
	default: table
	options:
	  - table
	  - json
	  - yaml
	  - csv
	---

wp profile eval-file

Profile execution of an arbitrary file.

wp profile eval-file <file> [--fields=<fields>] [--format=<format>]

File execution happens after WordPress has loaded entirely, which means you can use any utilities defined in WordPress, active plugins, or the current theme.

OPTIONS

<file>
	The path to the PHP file to execute and profile.

[--fields=<fields>]
	Display one or more fields.

[--format=<format>]
	Render output in a particular format.
	---
	default: table
	options:
	  - table
	  - json
	  - yaml
	  - csv
	---

Installing

wp profile is available to runcommand gold and silver subscribers, or you can purchase a single-seat updates and support subscription for $129 per year.

Once you've signed up, you can install wp profile with:

$ wp package install profile.zip

If you have a Github developer seat, you can also run:

$ wp package install git@github.com:runcommand/profile.git

See documentation for alternative installation instructions.

Support

Support is available to paying runcommand customers.

Have access to Sparks, the runcommand issue tracker? Feel free to open a new issue.

Think youve found a bug? Before you create a new issue, you should search existing issues to see if theres an existing resolution to it, or if its already been fixed in a newer version. Once youve done a bit of searching and discovered there isnt an open or fixed issue for your bug, please create a new issue with description of what you were doing, what you saw, and what you expected to see.

Want to contribute a new feature? Please first open a new issue to discuss whether the feature is a good fit for the project. Once you've decided to work on a pull request, please include functional tests and follow the WordPress Coding Standards.

Don't have access to Sparks? You can also email support@runcommand.io with general questions, bug reports, and feature suggestions.