2016-07-25 07:36:55 -07:00
runcommand/profile
==================
2016-08-29 06:51:40 -07:00
Quickly identify what's slow with WordPress.
2016-07-25 07:36:55 -07:00
2016-11-01 06:58:33 -07:00
[](https://runcommand.io/pricing/) [](https://circleci.com/gh/runcommand/profile/tree/master)
2016-08-30 07:05:50 -07:00
Quick links: [Overview ](#overview ) | [Using ](#using ) | [Installing ](#installing ) | [Support ](#support )
## Overview
2016-08-29 07:20:58 -07:00
`wp profile` monitors key performance indicators of the WordPress execution process to help you quickly identify points of slowness.
2016-07-25 07:36:55 -07:00
2016-11-01 06:58:33 -07:00
Save hours diagnosing slow WordPress sites with `wp profile` . 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 request ](https://runcommand.io/to/profile-wp-rest-api/ )).
2016-07-25 07:36:55 -07:00
2016-11-01 06:58:33 -07:00
First, run `wp profile stage` to see metrics for each stage of the WordPress load process. Use the `--url=<url>` argument to mock the request as a specific URL.
2016-07-25 10:17:10 -07:00
```
2016-11-01 06:58:33 -07:00
$ wp profile stage --url=runcommand.io
2016-08-29 06:51:40 -07:00
+------------+---------+------------+-------------+-------------+------------+--------------+-----------+------------+--------------+---------------+
| stage | time | query_time | query_count | cache_ratio | cache_hits | cache_misses | hook_time | hook_count | request_time | request_count |
+------------+---------+------------+-------------+-------------+------------+--------------+-----------+------------+--------------+---------------+
2016-10-31 06:47:15 -07:00
| bootstrap | 0.7597s | 0.0052s | 14 | 93.21% | 357 | 26 | 0.3328s | 2717 | 0s | 0 |
| main_query | 0.0131s | 0.0004s | 3 | 94.29% | 33 | 2 | 0.0065s | 78 | 0s | 0 |
| template | 0.7041s | 0.0192s | 147 | 92.16% | 2350 | 200 | 0.6982s | 6130 | 0s | 0 |
2016-08-29 06:51:40 -07:00
+------------+---------+------------+-------------+-------------+------------+--------------+-----------+------------+--------------+---------------+
2016-10-31 06:47:15 -07:00
| total (3) | 1.477s | 0.0248s | 164 | 93.22% | 2740 | 228 | 1.0375s | 8925 | 0s | 0 |
2016-08-29 06:51:40 -07:00
+------------+---------+------------+-------------+-------------+------------+--------------+-----------+------------+--------------+---------------+
2016-07-25 10:17:10 -07:00
```
2016-11-01 06:58:33 -07:00
Then, run `wp profile stage bootstrap` to dive into higher fidelity of a particular stage. Include the `--spotlight` flag to filter out the zero-ish results.
2016-08-29 07:20:58 -07:00
```
2016-11-01 06:58:33 -07:00
$ wp profile stage bootstrap --url=runcommand.io --spotlight
2016-10-31 06:47:15 -07:00
+--------------------------+----------------+---------+------------+-------------+-------------+------------+--------------+--------------+---------------+
| hook | callback_count | time | query_time | query_count | cache_ratio | cache_hits | cache_misses | request_time | request_count |
+--------------------------+----------------+---------+------------+-------------+-------------+------------+--------------+--------------+---------------+
| muplugins_loaded:before | | 0.1644s | 0.0017s | 1 | 40% | 2 | 3 | 0s | 0 |
| muplugins_loaded | 2 | 0.0005s | 0s | 0 | 50% | 1 | 1 | 0s | 0 |
| plugins_loaded:before | | 0.1771s | 0.0008s | 6 | 77.63% | 59 | 17 | 0s | 0 |
| plugins_loaded | 14 | 0.0887s | 0s | 0 | 100% | 104 | 0 | 0s | 0 |
| after_setup_theme:before | | 0.043s | 0s | 0 | 100% | 26 | 0 | 0s | 0 |
| init | 82 | 0.1569s | 0.0018s | 7 | 96.88% | 155 | 5 | 0s | 0 |
| wp_loaded:after | | 0.027s | 0s | 0 | | 0 | 0 | 0s | 0 |
+--------------------------+----------------+---------+------------+-------------+-------------+------------+--------------+--------------+---------------+
| total (7) | 98 | 0.6575s | 0.0043s | 14 | 77.42% | 347 | 26 | 0s | 0 |
+--------------------------+----------------+---------+------------+-------------+-------------+------------+--------------+--------------+---------------+
2016-08-29 07:20:58 -07:00
```
2016-11-01 06:58:33 -07:00
Lastly, when you've found a specific hook you'd like to assess, run `wp profile hook <hook>` . Use the `--fields=<fields>` argument to focus on certain fields.
2016-08-29 07:20:58 -07:00
```
2016-11-01 06:58:33 -07:00
$ wp profile hook plugins_loaded --url=runcommand.io --fields=callback,time,location
2016-10-31 06:49:51 -07:00
+------------------------------------------------------------+---------+-----------------------------------------------------------------+
| callback | time | location |
+------------------------------------------------------------+---------+-----------------------------------------------------------------+
| wp_maybe_load_widgets() | 0.0046s | wp-includes/functions.php:3501 |
| wp_maybe_load_embeds() | 0.0003s | wp-includes/embed.php:162 |
| VaultPress_Hotfixes->protect_jetpack_402_from_oembed_xss() | 0s | vaultpress/class.vaultpress-hotfixes.php:124 |
| _wp_customize_include() | 0s | wp-includes/theme.php:2052 |
| EasyRecipePlus->pluginsLoaded() | 0.0013s | easyrecipeplus/lib/EasyRecipePlus.php:125 |
| Gamajo\GenesisHeaderNav\genesis_header_nav_i18n() | 0.0007s | genesis-header-nav/genesis-header-nav.php:61 |
| DS_Public_Post_Preview::init() | 0.0001s | public-post-preview/public-post-preview.php:52 |
| wpseo_load_textdomain() | 0.0004s | wordpress-seo-premium/wp-seo-main.php:222 |
| load_yoast_notifications() | 0.0016s | wordpress-seo-premium/wp-seo-main.php:381 |
| wpseo_init() | 0.0329s | wordpress-seo-premium/wp-seo-main.php:240 |
| wpseo_premium_init() | 0.0019s | wordpress-seo-premium/wp-seo-premium.php:79 |
| wpseo_frontend_init() | 0.0007s | wordpress-seo-premium/wp-seo-main.php:274 |
| Black_Studio_TinyMCE_Plugin->load_compatibility() | 0.0016s | black-studio-tinymce-widget/black-studio-tinymce-widget.php:206 |
| Jetpack::load_modules() | 0.0564s | jetpack/class.jetpack.php:1672 |
+------------------------------------------------------------+---------+-----------------------------------------------------------------+
| total (14) | 0.1026s | |
+------------------------------------------------------------+---------+-----------------------------------------------------------------+
2016-08-29 07:20:58 -07:00
```
Et voila! You've identified some of the sources of slowness.
## Using
2016-10-04 06:49:18 -07:00
This package implements the following commands:
### wp profile stage
Profile each stage of the WordPress load process (bootstrap, main_query, template).
2016-08-29 07:20:58 -07:00
~~~
2016-10-26 05:40:34 -07:00
wp profile stage [< stage > ] [--all] [--spotlight] [--url=< url > ] [--fields=< fields > ] [--format=< format > ]
2016-08-29 07:20:58 -07:00
~~~
2016-07-25 08:14:12 -07:00
**OPTIONS**
2016-10-04 06:49:18 -07:00
[< stage > ]
Drill down into a specific stage.
2016-10-10 15:05:40 -07:00
[--all]
Expand upon all stages.
2016-10-26 05:40:34 -07:00
[--spotlight]
Filter out logs with zero-ish values from the set.
2016-07-25 08:14:12 -07:00
[--url=< url > ]
Execute a request against a specified URL. Defaults to the home URL.
2016-10-04 06:49:18 -07:00
[--fields=< fields > ]
2016-10-19 05:27:31 -07:00
Limit the output to specific fields. Default is all fields.
2016-10-04 06:49:18 -07:00
[--format=< format > ]
Render output in a particular format.
2016-08-29 06:51:40 -07:00
---
2016-10-04 06:49:18 -07:00
default: table
2016-08-29 06:51:40 -07:00
options:
2016-10-04 06:49:18 -07:00
- table
- json
- yaml
- csv
2016-08-29 06:51:40 -07:00
---
2016-10-04 06:49:18 -07:00
### wp profile hook
2016-10-10 15:05:40 -07:00
Profile key metrics for WordPress hooks (actions and filters).
2016-10-04 06:49:18 -07:00
~~~
2016-10-26 05:40:34 -07:00
wp profile hook [< hook > ] [--all] [--spotlight] [--url=< url > ] [--fields=< fields > ] [--format=< format > ]
2016-10-04 06:49:18 -07:00
~~~
2016-10-12 05:01:32 -07:00
In order to profile callbacks on a specific hook, the action or filter
will need to execute during the course of the request.
2016-10-04 06:49:18 -07:00
**OPTIONS**
2016-10-10 15:05:40 -07:00
[< hook > ]
Drill into key metrics of callbacks on a specific WordPress hook.
[--all]
Profile callbacks for all WordPress hooks.
2016-10-04 06:49:18 -07:00
2016-10-26 05:40:34 -07:00
[--spotlight]
Filter out logs with zero-ish values from the set.
2016-10-04 06:49:18 -07:00
[--url=< url > ]
Execute a request against a specified URL. Defaults to the home URL.
2016-08-29 06:51:40 -07:00
2016-07-25 10:17:10 -07:00
[--fields=< fields > ]
Display one or more fields.
2016-07-25 08:14:12 -07:00
[--format=< format > ]
Render output in a particular format.
---
default: table
options:
- table
- json
- yaml
- csv
---
2016-10-04 12:57:10 -07:00
### wp profile eval
Profile arbitrary code execution.
~~~
wp profile eval < php-code > [--fields=< fields > ] [--format=< format > ]
~~~
2016-10-04 14:38:12 -07:00
Code execution happens after WordPress has loaded entirely, which means
you can use any utilities defined in WordPress, active plugins, or the
current theme.
2016-10-04 12:57:10 -07:00
**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
---
2016-10-04 14:38:12 -07:00
### 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
---
2016-07-25 07:36:55 -07:00
## Installing
2016-10-31 06:47:15 -07:00
`wp profile` is available to [runcommand gold and silver subscribers ](https://runcommand.io/pricing/ ), or you can purchase a single-seat updates and support subscription for [$129 per year ](https://runcommand.memberful.com/checkout?plan=16079 ).
2016-08-29 08:01:34 -07:00
2016-10-31 06:47:15 -07:00
Once you've signed up, you can install `wp profile` with:
2016-07-25 07:36:55 -07:00
2016-08-29 15:38:54 -07:00
```
2016-10-31 06:47:15 -07:00
$ wp package install profile.zip
2016-08-29 15:38:54 -07:00
```
2016-10-31 06:47:15 -07:00
If you have a Github developer seat, you can also run:
2016-08-29 15:38:54 -07:00
```
2016-10-31 06:47:15 -07:00
$ wp package install git@github .com:runcommand/profile.git
2016-08-29 15:38:54 -07:00
```
2016-07-25 07:36:55 -07:00
2016-10-31 06:47:15 -07:00
See documentation for [alternative installation instructions ](https://runcommand.io/to/require-file-wp-cli-yml/ ).
2016-08-30 07:05:50 -07:00
## Support
2016-07-25 07:36:55 -07:00
2016-09-30 06:49:10 -07:00
Support is available to paying [runcommand ](https://runcommand.io/ ) customers.
2016-07-25 07:36:55 -07:00
2016-09-30 06:49:10 -07:00
Have access to [Sparks ](https://github.com/runcommand/sparks/ ), the runcommand issue tracker? Feel free to [open a new issue ](https://github.com/runcommand/sparks/issues/new ).
Think you’ ve found a bug? Before you create a new issue, you should [search existing issues ](https://github.com/runcommand/sparks/issues?q=label%3Abug%20 ) to see if there’ s an existing resolution to it, or if it’ s already been fixed in a newer version. Once you’ ve done a bit of searching and discovered there isn’ t an open or fixed issue for your bug, please [create a new issue ](https://github.com/runcommand/sparks/issues/new ) 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 ](https://github.com/runcommand/sparks/issues/new ) 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 ](https://wp-cli.org/docs/pull-requests/#functional-tests ) and follow the [WordPress Coding Standards ](http://make.wordpress.org/core/handbook/coding-standards/ ).
Don't have access to Sparks? You can also email [support@runcommand.io ](mailto:support@runcommand.io ) with general questions, bug reports, and feature suggestions.
2016-07-25 07:36:55 -07:00
2016-08-30 07:05:50 -07:00