Skip to content

Add --plugin grouping to wp profile hook resource output#220

Draft
Copilot wants to merge 10 commits into
mainfrom
copilot/profile-plugin-resource-usage
Draft

Add --plugin grouping to wp profile hook resource output#220
Copilot wants to merge 10 commits into
mainfrom
copilot/profile-plugin-resource-usage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 28, 2026

wp profile could not report resource usage at plugin granularity when profiling hooks. This change adds a plugin-level view so callback metrics can be aggregated per plugin via a first-class CLI flag.

  • Hook command surface

    • Added --plugin to wp profile hook options.
    • Updated command synopsis/docs (README.md, feature usage output) to include the new flag.
  • Plugin-level aggregation

    • Added grouping path in Command::hook() to aggregate callback metrics by plugin when --plugin is set.
    • Aggregates time, query/cache/request counters and durations, and computes aggregate cache_ratio.
    • Supports both standard plugins and mu-plugins by deriving plugin slug from callback location.
  • Behavior constraints

    • --plugin is only valid when profiling callbacks (wp profile hook <hook> or --all).
    • Returns a clear error if used on hook summary mode.
  • Acceptance coverage

    • Added Behat scenario validating plugin-grouped output for a test plugin on init.
wp profile hook init --plugin --fields=plugin,cache_hits,cache_misses

Example output shape:

+---------------+------------+--------------+
| plugin        | cache_hits | cache_misses |
+---------------+------------+--------------+
| resource-test | 0          | 1            |
+---------------+------------+--------------+
| total (1)     | 0          | 1            |
+---------------+------------+--------------+

Copilot AI linked an issue May 28, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 28, 2026 11:08
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 table of plugin resource usage with --plugin Add --plugin grouping to wp profile hook resource output May 28, 2026
Copilot AI requested a review from swissspidy May 28, 2026 11:12
Comment thread features/profile-hook.feature
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI requested a review from swissspidy May 28, 2026 11:25
@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Copilot AI and others added 2 commits June 2, 2026 09:40
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 68.83117% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Command.php 68.83% 24 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new --plugin flag to wp profile hook so hook callback metrics can be aggregated and displayed at plugin granularity (including mu-plugins), with docs and Behat coverage updated accordingly.

Changes:

  • Added --plugin flag to wp profile hook and implemented plugin-level aggregation of callback metrics.
  • Updated CLI documentation/usage strings to include the new flag.
  • Added a Behat scenario for plugin-grouped output and a dev dependency to support plugin activation in tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Command.php Adds --plugin option handling, plugin grouping aggregation, and plugin slug extraction from callback location.
README.md Documents the new --plugin flag in synopsis/options.
features/profile.feature Updates usage output to include --plugin.
features/profile-hook.feature Adds acceptance coverage for --plugin grouped output.
composer.json Adds wp-cli/extension-command to dev dependencies (used by the new Behat scenario).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Command.php Outdated
Comment thread src/Command.php Outdated
Comment thread src/Command.php Outdated
Comment thread README.md
swissspidy and others added 3 commits June 2, 2026 14:58
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Profile plugin resource usage with --plugin

3 participants