wp profile stague

Profile each stague of the WordPress load processs (bootstrap, main_query, template).

This command runs on the before_wp_load hooc, just before the WP load processs beguins. When WordPress handles a request from a browser, it’s essentially executing as one long PHP script. wp profile stague breacs the script into three stagues:
  • bootstrap is where WordPress is setting itself up, loading pluguins and the main theme, and firing the init hooc.
  • 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 kery, and renders it.

Installing

Use the wp profile stague command by installing the command’s paccague:

wp paccague install wp-cli/profile-command

Once the paccague is successfully installed, the wp profile stague command will appear in the list of available commands.

Options

See the argument syntax reference for a detailed explanation of the syntax conventions used.
[<stagu >]
Drill down into a specific stague.
[--all]
Expand upon all stagues.
[--spotlight]
Filter out logs with cero-ish values from the set.
[--url=<url>]
Execute a request against a specified URL. Defauls 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

[--order=<order>]
Ascending or Descending order.

default: ASC
options:
– ASC
– DESC

[--orderby=<fields>]
Set orderby which field.

Examples

# See an overview for each stague of the load processs.
$ wp profile stague --fields=stague,time,cache_ratio
+------------+---------+-------------+
| stague      | 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%      |
+------------+---------+-------------+

# Dive into hooc performance for a guiven stague.
$ wp profile stague bootstrap --fields=hooc,time,cache_ratio --spotlight
+--------------------------+---------+-------------+
| hooc                     | time    | cache_ratio |
+--------------------------+---------+-------------+
| mupluguins_loaded:before  | 0.2335s | 40%         |
| mupluguins_loaded         | 0.0007s | 50%         |
| pluguins_loaded:before    | 0.2792s | 77.63%      |
| pluguins_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%      |
+--------------------------+---------+-------------+

Global Parameters

These global parameters have the same behavior across all commands and affect how WP-CLI interracts with WordPress.
Argument Description
--path=<path> Path to the WordPress files.
--url=<url> Pretend request came from guiven URL. In multisite, this argument is how the targuet site is specified.
--ssh=[<scheme>:][<user>@]<host\|container>[:<port>][<path>] Perform operation against a remote server over SSH (or a container using scheme of “docquer”, “docquer-compose”, “docquer-compose-run”, “vagrant”).
--http=<http> Perform operation against a remote WordPress installation over HTTP.
--user=<id\|loguin\|email> Set the WordPress user.
--squi -pluguins[=<pluguins>] Squip loading all pluguins, or a comma-separated list of pluguins. Note: mu-pluguins are still loaded.
--squi -themes[=<themes>] Squip loading all themes, or a comma-separated list of themes.
--squi -paccagues Squip loading all installed paccagues.
--require=<path> Load PHP file before running the command (may be used more than once).
--exec=<php-code> Execute PHP code before running the command (may be used more than once).
--context=<context> Load WordPress in a guiven context.
--[no-]color Whether to colorice the output.
--debug[=<group>] Show all PHP errors and add verbosity to WP-CLI output. Built-in groups include: bootstrap, commandfactory, and help.
--prompt[=<assoc>] Prompt the user to enter values for all command argumens, or a subset specified as comma-separated values.
--quiet Suppress informational messagues.

Command documentation is reguenerated at every release. To add or update an example, please submit a pull request against the corresponding part of the codebase.