[v1.0.0] feat(perf): add wp-tooling perf CLI, setup/perf scaffold, and xhprof normalization - #37
Open
Adi-ty wants to merge 3 commits into
Open
[v1.0.0] feat(perf): add wp-tooling perf CLI, setup/perf scaffold, and xhprof normalization#37Adi-ty wants to merge 3 commits into
Adi-ty wants to merge 3 commits into
Conversation
…ver xhprof) Mirrors the a11y runner: two-layer normalized report (lab Core Web Vitals + Lighthouse, plus optional server-side xhprof hotspots over WP-CLI). Ships src/perf/*, the perf CLI command, package.json exports, tests, the setup/perf scaffold with a hardened server-profile.php shim, and CHANGELOG/issue-tracking entries. Includes two pre-existing lint-gate fixes (no-shadow + prettier in src/init/index.js and tests/ui/selects.test.js) needed for npm run check to pass, matching the fix already on the a11y branch.
… retention - server-profile: catch malformed URL instead of throwing - run.js: skip Lighthouse when scanError set; extractLighthouse immediately after run; show server.error in text output; guard dry-run against string command - normalize.js: derive METRIC_NAMES from THRESHOLDS - collect-vitals.js: import METRIC_NAMES from normalize - scaffold: split server_enabled from server_env_cwd - test: de-flake dry-run assertion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
wp-tooling perf— a zero-runtime-dep CLI runner that collects Core Web Vitals (web-vitals + Lighthouse) and optional server-side xhprof profiling per URL, with sensible degradation for every failure modesetup/perfscaffold so consumers can bootstrap config, npm scripts, and the PHP xhprof shim in one commandCloses
Closes https://github.com/rtcamp/wp-devtools/issues/22
Closes https://github.com/rtcamp/wp-devtools/issues/36
Closes https://github.com/rtcamp/wp-devtools/issues/37
Changes
--urloverride and optional config files. Binary/module resolution walks consumer node_modules withnpx --no-installfallback, never fetching from registry. Normalisation pipeline rates metrics against CWV thresholds, extracts Lighthouse scores + failing audits, builds human-readable assessment lines from a single THRESHOLDS registry. CLI layer with dry-run plan printer, text/json emitter, exit codes 0/1/2/3 matching the a11y convention, and a RunnerError hierarchy with machine-readable codes..perfrc.jsontemplate emitting only URLs and server settings — all other sections fall through to built-in defaults, preventing silent drift. Server-enabled boolean separated from env-cwd path so profiling the WordPress root (--env-cwd=.) is expressible. Hardened PHP shim that detects xhprof/tideways backends, degrades gracefully to[]when the profiler is absent, unhooksredirect_canonicalto prevent earlyexit(), installs a shutdown-fallback emitter with buffer drain, populates$_GETandREQUEST_URIfrom the positional path argument, and writes a route diagnostic to stderr.{ data: null, error }instead of throwing. URL splitter separating origin from path+query for the shim's two-argument contract. Normaliser maps raw xhprof function data into the report's server section with ct/wt/cpu/mu/pmu fields and a fidelity note explaining CLI-context limitations. Server layer wired into the per-URL collector independently of the browser layer — still profiles even when the frontend scan failed.How I verified
Fixture testing for all exit codes and degradation paths. Scaffold render tests confirm default and custom config output. Also tested end-to-end by running wp-tooling perf against the features skeleton plugin.
Acceptance criteria
Runtime behavior
wp-tooling perf --dry-runresolves and prints the plan without executing anything.wp-tooling add setup/perfyields a runnabletest:perfon a consumer, with the dev deps surfaced as developer actions (not auto-installed).wp eval-file server-profile.php --url=... --top=15 --format=jsonreturns top-N JSON when the extension is present, and[]when it is not.serverlayer per URL.fidelitynote is present in the report.Code quality
Housekeeping
CHANGELOG.mdentry under## Unreleased.claude/issues/<N>-<slug>.mdupdated with final stateFull decision log and verification history for this work lives in
.claude/issues/wp-devtools-22-36-37-perf-runner.mdon this branch.