diff --git a/packages/docs/src/components/InReview.astro b/packages/docs/src/components/InReview.astro new file mode 100644 index 00000000..c111601a --- /dev/null +++ b/packages/docs/src/components/InReview.astro @@ -0,0 +1,25 @@ +--- +import type { MeasurementName } from '@framework-performance/results/measurements-config' +import { isMeasurementShown } from '../lib/measurement-status' + +/** + * For a new benchmark, leave the section title visible so its table of contents + * link still works. Wrap everything under the title in , + * using the measurement key or an array of keys for a shared section. + * Keep the wrapper for a while after marking the benchmark live so you can + * switch it back to in-review if you find an issue with the results. + */ +interface Props { + test: MeasurementName | MeasurementName[] +} + +const tests = [Astro.props.test].flat() +--- + +{ + tests.every(isMeasurementShown) ? ( + + ) : ( +

This benchmark is in review. Results are coming soon.

+ ) +} diff --git a/packages/docs/src/lib/measurement-status.ts b/packages/docs/src/lib/measurement-status.ts new file mode 100644 index 00000000..ec73cc24 --- /dev/null +++ b/packages/docs/src/lib/measurement-status.ts @@ -0,0 +1,12 @@ +import { + measurementsConfig, + type MeasurementName, +} from '@framework-performance/results/measurements-config' + +// Cloudflare Workers Builds deploys the production site from main +const isProductionBuild = process.env.WORKERS_CI_BRANCH === 'main' + +/** In-review tests show in local builds and deploy previews, not production */ +export function isMeasurementShown(name: MeasurementName) { + return !isProductionBuild || measurementsConfig[name].status === 'live' +} diff --git a/packages/results/src/measurements-config.ts b/packages/results/src/measurements-config.ts index 3743c471..331a98fc 100644 --- a/packages/results/src/measurements-config.ts +++ b/packages/results/src/measurements-config.ts @@ -10,15 +10,19 @@ const ssrLoad = { const interactionScenarioLabel = 'first-row-detail-navigation' +/** `in-review` tests only show in local builds and deploy previews, not the production site. */ +export type MeasurementStatus = 'live' | 'in-review' + /** Shared defaults for every framework. Scans run once; benchmarks repeat. */ export const measurementsConfig = { - install: { runs: 5 }, - build: { runs: 5 }, - devServer: { runs: 5 }, - dependencies: null, - browserBaseline: null, - nodeEngines: null, + install: { status: 'live', runs: 5 }, + build: { status: 'live', runs: 5 }, + devServer: { status: 'live', runs: 5 }, + dependencies: { status: 'live' }, + browserBaseline: { status: 'live' }, + nodeEngines: { status: 'live' }, ssrRequestThroughput: { + status: 'live', runs: 5, durationMs: 10_000, warmupDurationMs: 250, @@ -27,23 +31,30 @@ export const measurementsConfig = { path: '/ssr-throughput', }, ssrLoad: { + status: 'live', ...ssrLoad, plainLinksPath: '/server-side-rendered-plain-links', }, - ssrRouterLinkLoad: { ...ssrLoad }, + ssrRouterLinkLoad: { status: 'live', ...ssrLoad }, clientSideRendered: { + status: 'live', runs: 5, scenario: interactionScenarioLabel, path: '/client-side-rendered', }, serverSideRendered: { + status: 'live', runs: 5, scenario: interactionScenarioLabel, path: '/server-side-rendered', }, initialLoad: { + status: 'live', path: '/initial-load', }, -} as const +} as const satisfies Record< + string, + { status: MeasurementStatus; [setting: string]: unknown } +> export type MeasurementName = keyof typeof measurementsConfig