Performance Gates
The X-Pollora-Diagnostics header, the query budgets per page type and the nightly boot, discovery and thumbnail measures of the framework.
The Pollora framework checks its own cost in its browser tests: how many SQL queries each type of page runs, and how long the boot, a cold discovery and a thumbnail take. This page describes the diagnostic header those checks read, the query budgets and the nightly measures. They belong to the framework’s repository (tests/e2e); the header is the part a project can use too.
The diagnostic header
Section titled “The diagnostic header”A request that sends X-Pollora-Diagnostics: 1 gets a report of what it cost, as long as WP_DEBUG is on:
curl -s -H 'X-Pollora-Diagnostics: 1' https://example.test/ | tail -3curl -sI -H 'X-Pollora-Diagnostics: 1' https://example.test/wp-json/ | grep -i x-pollora-diagnosticsThe report holds four values:
| Key | Meaning |
|---|---|
wordpress_queries | Queries WordPress ran through $wpdb ($wpdb->num_queries) |
laravel_queries | Queries Laravel ran, counted on its QueryExecuted event |
boot_ms | Milliseconds from the start of the request to wp_loaded |
elapsed_ms | Milliseconds from the start of the request to the report |
Where it appears depends on the response:
- A REST response carries it in the
X-Pollora-Diagnosticsresponse header, as JSON. - An HTML page carries it in a trailing comment after the document:
<!-- pollora:diagnostics {...} -->. Redirects, JSON, XML (feeds, sitemaps) and plain text never get one, and neither do wp-admin screens and admin-ajax calls.
Nothing is reported unless both conditions hold: WP_DEBUG is true and the request sends the header. A production site, where WP_DEBUG is false, never reports anything, whatever a visitor sends. A request without the header costs nothing: no hook is registered for it. The report does not depend on the debug bar.
Query budgets per page type
Section titled “Query budgets per page type”tests/e2e/specs/query-budget.spec.ts asks seven types of page for their own cost: home, post, page, archive, 404, search and REST. It fails when one runs more queries than tests/e2e/budgets.json allows, counted separately in WordPress and in Laravel.
- The margin is zero: counts are deterministic. Fewer queries than the budget passes.
0is a real limit: a page allowed no Laravel query fails on the first one.nullmeans no budget yet: the page is measured and reported, never failed.- Raising a budget is a deliberate edit of
budgets.json, reviewed like code. Lowering one keeps a gain.
The budgets are those of the CI site, a fresh install plus the fixtures of the suite. Another site has other counts. The pages measured are /?p=1, /?page_id=2 and /?cat=1, the content WordPress creates on install.
To write the measured counts into budgets.json:
npm run budgets:update # sets E2E_UPDATE_BUDGETS=1, measures, then writes the fileRun it against a site like the CI one, or take the first measure from a green CI run: every run writes test-results/budgets.measured.json and the CI uploads it as the e2e-budgets-measured-* artifact. Commit the result.
The budgets are strict since v13.43.0: home 24, post 20, page 19, archive 26, 404 15, search 22, REST 19 WordPress queries, and 0 Laravel queries on every page. Read tests/e2e/budgets.json for the current values.
Nightly measures
Section titled “Nightly measures”tests/e2e/specs/perf-metrics.spec.ts runs only when E2E_PERF=1, which the nightly job sets. It writes perf-metrics.json with three values, each the median of several runs:
| Metric | Measures |
|---|---|
boot_ms | A warm boot, up to wp_loaded |
cold_boot_ms | The first request after php artisan discovery:clear, so with discovery rebuilt from scratch |
thumbnail_ms | Generating every size of one 2400x1600 JPEG |
The job compares them with the last night that passed (bin/perf-compare.ts) and fails when one is more than 10 % slower. The reference is restored through actions/cache. A failing night does not replace the reference, so a regression cannot become the new normal. To accept a slowdown on purpose, delete the perf07-reference-* cache entries.
To run it by hand:
E2E_PERF=1 npx playwright test perf-metricsnode bin/perf-compare.ts current.json reference.json --tolerance=0.1See also
Section titled “See also”- Debugging — the debug bar, for a closer look at the queries a page runs
- Testing a Pollora Project — unit and feature tests of your own project