Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

Adds Daniel Bachhuber's wp profile tutorial to the handbook as a how-to guide.

Changes

  • New guide: how-to/figure-out-why-wordpress-is-slow.md

    • Installation instructions for the wp-cli/profile-command package
    • Profile WordPress load stages with wp profile stage
    • Drill into specific stages using --spotlight flag
    • Identify slow hooks with wp profile hook <hook>
  • Manifest registration: Added entry in bin/handbook-manifest.json

  • Index update: Linked guide from how-to.md

Example workflow

# Install the profile command package
$ wp package install wp-cli/profile-command

# See metrics for each load stage
$ wp profile stage --url=example.com

# Drill into slow bootstrap stage
$ wp profile stage bootstrap --spotlight

# Profile specific hook callbacks
$ wp profile hook plugins_loaded --fields=callback,time,location
Original prompt

This section details on the original issue you should resolve

<issue_title>Add how-to guide: "Figure out why WordPress is slow"</issue_title>
<issue_description>Let's get Daniel's now deleted blog post into the handbook:

Figure out why WordPress is slow with wp profile
With wp profile, you gain quick visibility into key performance metrics (execution time, query count, cache hit/miss ratio, etc.) to guide further debugging.

November 3, 2016
wp profile is a WP-CLI command to help you quickly identify what’s slow with WordPress. It’s designed to work alongside Xdebug and New Relic because it’s easy to deploy to any server that has WP-CLI. With wp profile, you gain quick visibility into key performance metrics (execution time, query count, cache hit/miss ratio, etc.) to guide further debugging.

Dealing with a slow WordPress install you’ve never worked with before? Run wp profile stage to see metrics for each stage of the WordPress load process. Include the --url=<url> argument to mock the request as a specific URL.

$ wp profile stage --url=runcommand.io
+------------+---------+------------+-------------+-------------+------------+--------------+-----------+------------+--------------+---------------+
| stage      | time    | query_time | query_count | cache_ratio | cache_hits | cache_misses | hook_time | hook_count | request_time | request_count |
+------------+---------+------------+-------------+-------------+------------+--------------+-----------+------------+--------------+---------------+
| 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             |
+------------+---------+------------+-------------+-------------+------------+--------------+-----------+------------+--------------+---------------+
| total (3)  | 1.477s  | 0.0248s    | 164         | 93.22%      | 2740       | 228          | 1.0375s   | 8925       | 0s           | 0             |
+------------+---------+------------+-------------+-------------+------------+--------------+-----------+------------+--------------+---------------+
When WordPress handles a request from a browser, it’s 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.
In the example from above, bootstrap seems a bit slow, so let’s dive into it further. Run wp profile stage bootstrap to dive into higher fidelity mode of a given stage. Use the --spotlight flag to filter out the zero-ish results.

$ wp profile stage bootstrap --url=runcommand.io --spotlight
+--------------------------+----------------+---------+------------+-------------+-------------+------------+--------------+--------------+---------------+
| 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             |
+--------------------------+----------------+---------+------------+-------------+-------------+------------+---...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes wp-cli/handbook#615

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/wp-cli/handbook/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 12, 2026 12:51
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add how-to guide for identifying WordPress slowness Add how-to guide: Figure out why WordPress is slow Jan 12, 2026
Copilot AI requested a review from swissspidy January 12, 2026 12:53
@swissspidy swissspidy requested a review from Copilot January 12, 2026 13:00

This comment was marked as resolved.

swissspidy and others added 2 commits January 12, 2026 14:21
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy swissspidy marked this pull request as ready for review January 12, 2026 13:41
@swissspidy swissspidy requested a review from a team as a code owner January 12, 2026 13:41
@swissspidy swissspidy merged commit df1aa93 into main Jan 12, 2026
6 checks passed
@swissspidy swissspidy deleted the copilot/add-how-to-guide-wordpress branch January 12, 2026 13:41
@swissspidy swissspidy linked an issue Jan 13, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add how-to guide: "Figure out why WordPress is slow"

2 participants