diff --git a/.github/workflows/generate-stats.yml b/.github/workflows/generate-stats.yml index edc84d260..e80341b7e 100644 --- a/.github/workflows/generate-stats.yml +++ b/.github/workflows/generate-stats.yml @@ -117,7 +117,7 @@ jobs: - name: Set matrices from TypeScript config id: set-matrix run: | - FRAMEWORKS=$(node packages/stats-generator/src/print-frameworks.ts) + FRAMEWORKS=$(node packages/stats-generator/src/scripts/print-frameworks.ts) echo "install=$(echo "$FRAMEWORKS" | jq -c '[.[] | select(.starter) | select(.measurements | (index("installDuration") != null or index("dependencyCounts") != null)) | {name, displayName, package: .starter.package, buildScript: .starter.buildScript, buildOutputDir: .starter.buildOutputDir, measurements}]')" >> $GITHUB_OUTPUT echo "build=$(echo "$FRAMEWORKS" | jq -c '[.[] | select(.starter) | select(.measurements | (index("buildDuration") != null or index("coreJS") != null or index("browserBaseline") != null)) | {name, displayName, package: .starter.package, buildScript: .starter.buildScript, buildOutputDir: .starter.buildOutputDir, measurements}]')" >> $GITHUB_OUTPUT echo "devServer=$(echo "$FRAMEWORKS" | jq -c '[.[] | select(.starter) | select(.measurements | index("devServerStartUpDuration") != null) | {name, displayName, package: .starter.package, devServerPort: .starter.devServerPort, measurements}]')" >> $GITHUB_OUTPUT diff --git a/.github/workflows/measure-framework.yml b/.github/workflows/measure-framework.yml index c1b5047ef..191b52d2c 100644 --- a/.github/workflows/measure-framework.yml +++ b/.github/workflows/measure-framework.yml @@ -282,13 +282,13 @@ jobs: if: contains(matrix.framework.measurements, 'dependencyCounts') env: FRAMEWORK_NAME: ${{ matrix.framework.name }} - run: node packages/stats-generator/src/run-framework-dependency-scan.ts "$FRAMEWORK_NAME" + run: node packages/stats-generator/src/run-benchmarks-scripts/run-framework-dependency-scan.ts "$FRAMEWORK_NAME" - name: Collect first-party dependency stats if: contains(matrix.framework.measurements, 'dependencyCounts') env: FRAMEWORK_NAME: ${{ matrix.framework.name }} - run: node packages/stats-generator/src/run-first-party-dependency-scan.ts "$FRAMEWORK_NAME" + run: node packages/stats-generator/src/run-benchmarks-scripts/run-first-party-dependency-scan.ts "$FRAMEWORK_NAME" - name: Scan installed dependencies for Node engine constraints if: contains(matrix.framework.measurements, 'minimumNodeVersion') diff --git a/.github/workflows/sync-version.yml b/.github/workflows/sync-version.yml index b7ae3be13..fb594843a 100644 --- a/.github/workflows/sync-version.yml +++ b/.github/workflows/sync-version.yml @@ -6,7 +6,6 @@ on: - 'packages/starter-*/package.json' - 'packages/app-*/package.json' - 'packages/results/**' - - 'packages/stats-generator/src/frameworks.ts' workflow_dispatch: # Allows manual triggering from GitHub Actions UI jobs: diff --git a/.gitignore b/.gitignore index 803b68aac..85906584d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,11 @@ node_modules/ !.yarn/versions # Build outputs -dist/ -build/ +/packages/app-*/dist/ +/packages/app-*/build/ +/packages/starter-*/dist/ +/packages/starter-*/build/ +/packages/docs/dist/ out/ .output/ dist-ssr/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 80168d4c6..db32a5d39 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -69,7 +69,7 @@ flowchart LR - [`frameworks-config.ts`](./packages/results/src/frameworks-config.ts) selects which measurements run for each starter and app. - Put benchmark settings in [`measurements-config.ts`](./packages/results/src/measurements-config.ts). For example, `install: { runs: 5 }` runs five install measurements per job for each enabled starter. Entries like `dependencies: null` have no configurable repeat count here. -Edit the TypeScript config. [`print-frameworks.ts`](./packages/stats-generator/src/print-frameworks.ts) +Edit the TypeScript config. [`print-frameworks.ts`](./packages/stats-generator/src/scripts/print-frameworks.ts) prints it as JSON so CI can build its benchmark matrices. Astro imports the same registry for framework names and ordering, and for validating Code Comparison slugs. diff --git a/knip.json b/knip.json index 22014d6ad..b8d9bb194 100644 --- a/knip.json +++ b/knip.json @@ -7,7 +7,7 @@ "entry": ["src/cwv/index.ts"] }, "packages/stats-generator": { - "entry": ["src/serve/*.ts"] + "entry": ["src/app-servers/*.ts"] } } } diff --git a/packages/docs/src/content/docs/methodology.md b/packages/docs/src/content/docs/methodology.md index c15d8cfbd..7f29a713d 100644 --- a/packages/docs/src/content/docs/methodology.md +++ b/packages/docs/src/content/docs/methodology.md @@ -268,7 +268,7 @@ pnpm dlx create-void starter-void --toolchain vite --framework react --starter s response body is not read, because several dev servers stream the page and body time would measure page size rather than startup. - The port is the starter's default dev port, recorded as `devServerPort` in - `packages/stats-generator/src/frameworks.ts`. The starters are not modified, so whatever they + `packages/results/src/frameworks-config.ts`. The starters are not modified, so whatever they ship is inside the measurement: Nuxt and TanStack Start enable devtools, and Astro and React Router generate types at boot. - The dev server runs with a minimal environment (`PATH`, `HOME`, `TMPDIR`, diff --git a/packages/stats-generator/package.json b/packages/stats-generator/package.json index d65a90fbe..a5d2135d8 100644 --- a/packages/stats-generator/package.json +++ b/packages/stats-generator/package.json @@ -4,35 +4,35 @@ "private": true, "type": "module", "scripts": { - "run:ssr-request-throughput": "node src/run-ssr-request-throughput-benchmark.ts", - "run:ssr-load": "node src/run-ssr-load-benchmark.ts", - "run:ssr-load:containerized": "node src/run-containerized-ssr-load.ts", - "run:ssr-router-link-load": "SSR_LOAD_KIND=ssrLoadRouterLinks node src/run-ssr-load-benchmark.ts", - "run:ssr-router-link-load:containerized": "SSR_LOAD_KIND=ssrLoadRouterLinks node src/run-containerized-ssr-load.ts", - "verify:ssr-load": "node src/verify-ssr-load.ts", - "serve:ssr-load": "node src/run-ssr-load-server.ts", - "run:client-side-rendered": "node src/run-client-side-rendered-benchmark.ts", - "run:server-side-rendered": "node src/run-server-side-rendered-benchmark.ts", - "run:ssr-initial-load": "node src/scripts/run-ssr-initial-load-benchmark.ts", - "run:ssr-initial-load-images": "node src/scripts/run-ssr-initial-load-images-benchmark.ts", - "run:ssr-initial-load-framework-images": "node src/scripts/run-ssr-initial-load-framework-images-benchmark.ts", - "run:install": "node src/run-install-benchmark.ts", - "run:build": "node src/run-build-benchmark.ts", - "run:dev-server": "node src/run-dev-server-benchmark.ts", - "run:corejs": "node src/run-corejs-scan.ts", - "run:browser-baseline": "node src/run-browser-baseline-scan.ts", - "run:framework-dependencies": "node src/run-framework-dependency-scan.ts", - "run:first-party-dependencies": "node src/run-first-party-dependency-scan.ts", - "run:node-engines": "node src/run-node-engines-scan.ts", - "validate:ci-stats": "node src/save-ci-stats.ts --validate-only", - "save:ci-stats": "node src/save-ci-stats.ts", - "validate": "node src/save-ci-stats.ts --validate-only", - "validate:first-party-dependencies": "node src/validate-first-party-dependencies.ts", - "sync:versions": "node src/sync-versions.ts", + "run:ssr-request-throughput": "node src/run-benchmarks-scripts/run-ssr-request-throughput-benchmark.ts", + "run:ssr-load": "node src/run-benchmarks-scripts/run-ssr-load-benchmark.ts", + "run:ssr-load:containerized": "node src/run-benchmarks-scripts/run-containerized-ssr-load.ts", + "run:ssr-router-link-load": "SSR_LOAD_KIND=ssrLoadRouterLinks node src/run-benchmarks-scripts/run-ssr-load-benchmark.ts", + "run:ssr-router-link-load:containerized": "SSR_LOAD_KIND=ssrLoadRouterLinks node src/run-benchmarks-scripts/run-containerized-ssr-load.ts", + "verify:ssr-load": "node src/benchmarks/ssr-load/verify-ssr-load.ts", + "serve:ssr-load": "node src/run-benchmarks-scripts/run-ssr-load-server.ts", + "run:client-side-rendered": "node src/run-benchmarks-scripts/run-client-side-rendered-benchmark.ts", + "run:server-side-rendered": "node src/run-benchmarks-scripts/run-server-side-rendered-benchmark.ts", + "run:ssr-initial-load": "node src/run-benchmarks-scripts/run-ssr-initial-load-benchmark.ts", + "run:ssr-initial-load-images": "node src/run-benchmarks-scripts/run-ssr-initial-load-images-benchmark.ts", + "run:ssr-initial-load-framework-images": "node src/run-benchmarks-scripts/run-ssr-initial-load-framework-images-benchmark.ts", + "run:install": "node src/run-benchmarks-scripts/run-install-benchmark.ts", + "run:build": "node src/run-benchmarks-scripts/run-build-benchmark.ts", + "run:dev-server": "node src/run-benchmarks-scripts/run-dev-server-benchmark.ts", + "run:corejs": "node src/run-benchmarks-scripts/run-corejs-scan.ts", + "run:browser-baseline": "node src/run-benchmarks-scripts/run-browser-baseline-scan.ts", + "run:framework-dependencies": "node src/run-benchmarks-scripts/run-framework-dependency-scan.ts", + "run:first-party-dependencies": "node src/run-benchmarks-scripts/run-first-party-dependency-scan.ts", + "run:node-engines": "node src/run-benchmarks-scripts/run-node-engines-scan.ts", + "validate:ci-stats": "node src/scripts/save-ci-stats.ts --validate-only", + "save:ci-stats": "node src/scripts/save-ci-stats.ts", + "validate": "node src/scripts/save-ci-stats.ts --validate-only", + "validate:first-party-dependencies": "node src/scripts/validate-first-party-dependencies.ts", + "sync:versions": "node src/scripts/sync-versions.ts", "lint": "eslint .", "lint:fix": "eslint . --fix", "type-check": "tsc --noEmit", - "test": "node --test src/*.test.ts" + "test": "node --test \"src/**/*.test.ts\"" }, "dependencies": { "autocannon": "^8.0.0", diff --git a/packages/stats-generator/src/serve/astro.ts b/packages/stats-generator/src/app-servers/astro.ts similarity index 100% rename from packages/stats-generator/src/serve/astro.ts rename to packages/stats-generator/src/app-servers/astro.ts diff --git a/packages/stats-generator/src/serve/baseline-html.ts b/packages/stats-generator/src/app-servers/baseline-html.ts similarity index 87% rename from packages/stats-generator/src/serve/baseline-html.ts rename to packages/stats-generator/src/app-servers/baseline-html.ts index fdfd9f163..4f71affbe 100644 --- a/packages/stats-generator/src/serve/baseline-html.ts +++ b/packages/stats-generator/src/app-servers/baseline-html.ts @@ -1,6 +1,6 @@ import { createServer } from 'node:http' import { testData } from '../../../testdata/src/ssr.ts' -import { renderBaselineHtml } from '../baseline-html.ts' +import { renderBaselineHtml } from '../benchmarks/shared/baseline-html.ts' import { getHost, getPort, registerShutdown } from './common.ts' const HOST = getHost() diff --git a/packages/stats-generator/src/benchmark-server.test.ts b/packages/stats-generator/src/app-servers/benchmark-server.test.ts similarity index 100% rename from packages/stats-generator/src/benchmark-server.test.ts rename to packages/stats-generator/src/app-servers/benchmark-server.test.ts diff --git a/packages/stats-generator/src/benchmark-server.ts b/packages/stats-generator/src/app-servers/benchmark-server.ts similarity index 95% rename from packages/stats-generator/src/benchmark-server.ts rename to packages/stats-generator/src/app-servers/benchmark-server.ts index 88a535a4c..c21767f4c 100644 --- a/packages/stats-generator/src/benchmark-server.ts +++ b/packages/stats-generator/src/app-servers/benchmark-server.ts @@ -3,7 +3,7 @@ import { once } from 'node:events' import { join } from 'node:path' import { setTimeout as sleep } from 'node:timers/promises' import { fileURLToPath } from 'node:url' -import { packagesDir } from './constants.ts' +import { packagesDir } from '../utils/paths.ts' export async function waitForBenchmarkServer( url: string, @@ -33,7 +33,7 @@ export async function startBenchmarkServer( ): Promise<() => Promise> { const { host, port, readinessPath, timeoutMs = 30_000 } = options const scriptPath = fileURLToPath( - new URL(`./serve/${config.serveScript}`, import.meta.url), + new URL(`./${config.serveScript}`, import.meta.url), ) const proc = spawn( process.execPath, diff --git a/packages/stats-generator/src/serve/common.ts b/packages/stats-generator/src/app-servers/common.ts similarity index 100% rename from packages/stats-generator/src/serve/common.ts rename to packages/stats-generator/src/app-servers/common.ts diff --git a/packages/stats-generator/src/serve/next.ts b/packages/stats-generator/src/app-servers/next.ts similarity index 100% rename from packages/stats-generator/src/serve/next.ts rename to packages/stats-generator/src/app-servers/next.ts diff --git a/packages/stats-generator/src/serve/nitro.ts b/packages/stats-generator/src/app-servers/nitro.ts similarity index 100% rename from packages/stats-generator/src/serve/nitro.ts rename to packages/stats-generator/src/app-servers/nitro.ts diff --git a/packages/stats-generator/src/serve/pracht.ts b/packages/stats-generator/src/app-servers/pracht.ts similarity index 100% rename from packages/stats-generator/src/serve/pracht.ts rename to packages/stats-generator/src/app-servers/pracht.ts diff --git a/packages/stats-generator/src/serve/react-router.ts b/packages/stats-generator/src/app-servers/react-router.ts similarity index 100% rename from packages/stats-generator/src/serve/react-router.ts rename to packages/stats-generator/src/app-servers/react-router.ts diff --git a/packages/stats-generator/src/server-warmup.ts b/packages/stats-generator/src/app-servers/server-warmup.ts similarity index 100% rename from packages/stats-generator/src/server-warmup.ts rename to packages/stats-generator/src/app-servers/server-warmup.ts diff --git a/packages/stats-generator/src/serve/solid.ts b/packages/stats-generator/src/app-servers/solid.ts similarity index 100% rename from packages/stats-generator/src/serve/solid.ts rename to packages/stats-generator/src/app-servers/solid.ts diff --git a/packages/stats-generator/src/serve/sveltekit.ts b/packages/stats-generator/src/app-servers/sveltekit.ts similarity index 100% rename from packages/stats-generator/src/serve/sveltekit.ts rename to packages/stats-generator/src/app-servers/sveltekit.ts diff --git a/packages/stats-generator/src/serve/tanstack-start.ts b/packages/stats-generator/src/app-servers/tanstack-start.ts similarity index 100% rename from packages/stats-generator/src/serve/tanstack-start.ts rename to packages/stats-generator/src/app-servers/tanstack-start.ts diff --git a/packages/stats-generator/src/serve/void.ts b/packages/stats-generator/src/app-servers/void.ts similarity index 100% rename from packages/stats-generator/src/serve/void.ts rename to packages/stats-generator/src/app-servers/void.ts diff --git a/packages/stats-generator/src/run-browser-baseline-scan.ts b/packages/stats-generator/src/benchmarks/browser-baseline/run-scan.ts similarity index 90% rename from packages/stats-generator/src/run-browser-baseline-scan.ts rename to packages/stats-generator/src/benchmarks/browser-baseline/run-scan.ts index ea5f63066..67e7b1bd8 100644 --- a/packages/stats-generator/src/run-browser-baseline-scan.ts +++ b/packages/stats-generator/src/benchmarks/browser-baseline/run-scan.ts @@ -8,13 +8,11 @@ import { detectFeatures, } from 'baseline-detector' import { glob } from 'tinyglobby' -import { packagesDir } from './constants.ts' -import { - benchmarkOutputPath, - getBenchmarkContext, - requireMeasurements, - writeJsonFile, -} from './utils.ts' +import { packagesDir } from '../../utils/paths.ts' +import { benchmarkOutputPath } from '../../utils/paths.ts' +import { writeJsonFile } from '../../utils/files.ts' + +import type { TestConfig } from '../../types.ts' type BaselineStatus = ReturnType< typeof BrowserBaselineBenchmark.parse @@ -85,12 +83,10 @@ async function stageBrowserBuildFiles(buildOutputPath: string) { } } -async function main() { - const { packageName, projectConfig, framework } = await getBenchmarkContext({ - project: 'starter', - }) - requireMeasurements(framework, ['browserBaseline']) - +export async function runBrowserBaselineScan( + packageName: string, + projectConfig: TestConfig, +) { const buildOutputPath = join( packagesDir, packageName, @@ -160,8 +156,3 @@ async function main() { await rm(scanDir, { recursive: true, force: true }) } } - -main().catch((error) => { - console.error('Browser baseline scan failed:', error) - process.exit(1) -}) diff --git a/packages/stats-generator/src/build-statistics.test.ts b/packages/stats-generator/src/benchmarks/build/build-statistics.test.ts similarity index 100% rename from packages/stats-generator/src/build-statistics.test.ts rename to packages/stats-generator/src/benchmarks/build/build-statistics.test.ts diff --git a/packages/stats-generator/src/build-statistics.ts b/packages/stats-generator/src/benchmarks/build/build-statistics.ts similarity index 90% rename from packages/stats-generator/src/build-statistics.ts rename to packages/stats-generator/src/benchmarks/build/build-statistics.ts index 0455ec27c..1bb4c1e77 100644 --- a/packages/stats-generator/src/build-statistics.ts +++ b/packages/stats-generator/src/benchmarks/build/build-statistics.ts @@ -1,4 +1,4 @@ -import { summarizeMetric } from './sample-statistics.ts' +import { summarizeMetric } from '../shared/sample-statistics.ts' import { BuildBenchmark } from '@framework-performance/results/benchmark-schemas' export function createBuildStats(cold: number[], warm: number[]) { diff --git a/packages/stats-generator/src/run-build-benchmark.ts b/packages/stats-generator/src/benchmarks/build/run-benchmark.ts similarity index 86% rename from packages/stats-generator/src/run-build-benchmark.ts rename to packages/stats-generator/src/benchmarks/build/run-benchmark.ts index a1a055a02..25f13e0b8 100644 --- a/packages/stats-generator/src/run-build-benchmark.ts +++ b/packages/stats-generator/src/benchmarks/build/run-benchmark.ts @@ -1,18 +1,16 @@ -import { measurementsConfig } from './measurements.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' import { execFileSync } from 'node:child_process' import { cpSync, rmSync } from 'node:fs' import { tmpdir } from 'node:os' import { isAbsolute, join, relative, resolve, sep } from 'node:path' -import { copyTrackedProject, installDependencies } from './benchmark-utils.ts' -import { packagesDir } from './constants.ts' -import { - benchmarkOutputPath, - writeJsonFile, - getBenchmarkContext, - requireMeasurements, -} from './utils.ts' +import { copyTrackedProject, installDependencies } from '../../utils/project.ts' +import { packagesDir } from '../../utils/paths.ts' +import { benchmarkOutputPath } from '../../utils/paths.ts' +import { writeJsonFile } from '../../utils/files.ts' import { createBuildStats } from './build-statistics.ts' -import { summarizeSamples } from './sample-statistics.ts' +import { summarizeSamples } from '../shared/sample-statistics.ts' + +import type { FrameworkConfig, TestConfig } from '../../types.ts' function measureBuildTime(cwd: string, buildScript: string): number { const start = performance.now() @@ -46,12 +44,11 @@ function getBuildOutputPath( return buildOutputPath } -async function main() { - const { packageName, framework, projectConfig } = await getBenchmarkContext({ - project: 'starter', - }) - requireMeasurements(framework, ['buildDuration', 'coreJS', 'browserBaseline']) - +export async function runBuildBenchmark( + packageName: string, + framework: FrameworkConfig, + projectConfig: TestConfig, +) { const runFrequency = measurementsConfig.build.runs console.info( @@ -142,8 +139,3 @@ async function main() { rmSync(tempDir, { recursive: true, force: true }) } } - -main().catch((error) => { - console.error('Build benchmark failed:', error) - process.exit(1) -}) diff --git a/packages/stats-generator/src/client-rendering.test.ts b/packages/stats-generator/src/benchmarks/client-side-rendered/client-rendering.test.ts similarity index 97% rename from packages/stats-generator/src/client-rendering.test.ts rename to packages/stats-generator/src/benchmarks/client-side-rendered/client-rendering.test.ts index 2d1fcebc8..4c1c7633d 100644 --- a/packages/stats-generator/src/client-rendering.test.ts +++ b/packages/stats-generator/src/benchmarks/client-side-rendered/client-rendering.test.ts @@ -2,7 +2,7 @@ import { test } from 'node:test' import assert from 'node:assert/strict' import { assembleClientRendering } from './client-rendering.ts' import { CSRLighthouseBenchmark } from '@framework-performance/results/benchmark-schemas' -import { measuredCSRLighthouse } from './rendered-sample-metrics.ts' +import { measuredCSRLighthouse } from '../shared/rendered-sample-metrics.ts' test('assembles client rendering from exact raw browser measurements', () => { const iterations = [1, 3].map((value) => ({ diff --git a/packages/stats-generator/src/client-rendering.ts b/packages/stats-generator/src/benchmarks/client-side-rendered/client-rendering.ts similarity index 88% rename from packages/stats-generator/src/client-rendering.ts rename to packages/stats-generator/src/benchmarks/client-side-rendered/client-rendering.ts index 56fd7de7e..26b55c0e3 100644 --- a/packages/stats-generator/src/client-rendering.ts +++ b/packages/stats-generator/src/benchmarks/client-side-rendered/client-rendering.ts @@ -1,9 +1,9 @@ import { renderedSampleMetrics, measuredCSRLighthouse, -} from './rendered-sample-metrics.ts' -import { summarizeMetric } from './sample-statistics.ts' -import type { RenderedTestSample } from './types.ts' +} from '../shared/rendered-sample-metrics.ts' +import { summarizeMetric } from '../shared/sample-statistics.ts' +import type { RenderedTestSample } from '../../types.ts' export function assembleClientRendering(iterations: RenderedTestSample[]) { return measuredCSRLighthouse.parse({ diff --git a/packages/stats-generator/src/clientSideRendered/index.ts b/packages/stats-generator/src/benchmarks/client-side-rendered/index.ts similarity index 81% rename from packages/stats-generator/src/clientSideRendered/index.ts rename to packages/stats-generator/src/benchmarks/client-side-rendered/index.ts index de117d8f2..71be35e64 100644 --- a/packages/stats-generator/src/clientSideRendered/index.ts +++ b/packages/stats-generator/src/benchmarks/client-side-rendered/index.ts @@ -1,7 +1,7 @@ -import { measurementsConfig } from '../measurements.ts' -import type { FrameworkConfig, TestConfig } from '../types.ts' -import { startBenchmarkServer } from '../benchmark-server.ts' -import { getHost } from '../serve/common.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import type { FrameworkConfig, TestConfig } from '../../types.ts' +import { startBenchmarkServer } from '../../app-servers/benchmark-server.ts' +import { getHost } from '../../app-servers/common.ts' import { runBenchmark } from './run-benchmark.ts' import type { ClientSideRenderedBenchmarkResult } from './types.ts' diff --git a/packages/stats-generator/src/clientSideRendered/run-benchmark.ts b/packages/stats-generator/src/benchmarks/client-side-rendered/run-benchmark.ts similarity index 93% rename from packages/stats-generator/src/clientSideRendered/run-benchmark.ts rename to packages/stats-generator/src/benchmarks/client-side-rendered/run-benchmark.ts index 0afcc82c5..f015b13aa 100644 --- a/packages/stats-generator/src/clientSideRendered/run-benchmark.ts +++ b/packages/stats-generator/src/benchmarks/client-side-rendered/run-benchmark.ts @@ -1,15 +1,15 @@ -import { findChromium } from '../find-chromium.ts' -import { measurementsConfig } from '../measurements.ts' -import { assembleClientRendering } from '../client-rendering.ts' +import { findChromium } from '../../utils/find-chromium.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import { assembleClientRendering } from './client-rendering.ts' import puppeteer from 'puppeteer-core' import { startFlow } from 'lighthouse' -import { warmUpServer } from '../server-warmup.ts' +import { warmUpServer } from '../../app-servers/server-warmup.ts' import { getInteractionTimingFromLighthouse, getNavigationInteractionTimingFromLighthouse, prepareInteractionTraceForLighthouse, -} from '../interaction-timing.ts' -import { getInteractionWorkFromTrace } from '../interaction-work.ts' +} from '../shared/interaction-timing.ts' +import { getInteractionWorkFromTrace } from '../shared/interaction-work.ts' import type { ClientSideRenderedBenchmarkResult, ClientSideRenderedRunResult, diff --git a/packages/stats-generator/src/clientSideRendered/types.ts b/packages/stats-generator/src/benchmarks/client-side-rendered/types.ts similarity index 79% rename from packages/stats-generator/src/clientSideRendered/types.ts rename to packages/stats-generator/src/benchmarks/client-side-rendered/types.ts index 5e616ae2e..61e8bc452 100644 --- a/packages/stats-generator/src/clientSideRendered/types.ts +++ b/packages/stats-generator/src/benchmarks/client-side-rendered/types.ts @@ -1,7 +1,7 @@ import type { z } from 'zod' import type { CSRLighthouseBenchmark } from '@framework-performance/results/benchmark-schemas' -import type { InteractionTiming } from '../types.ts' -import type { InteractionWork } from '../interaction-work.ts' +import type { InteractionTiming } from '../../types.ts' +import type { InteractionWork } from '../shared/interaction-work.ts' export interface ClientSideRenderedRunResult { firstPaint: number | null diff --git a/packages/stats-generator/src/run-corejs-scan.ts b/packages/stats-generator/src/benchmarks/core-js/run-scan.ts similarity index 88% rename from packages/stats-generator/src/run-corejs-scan.ts rename to packages/stats-generator/src/benchmarks/core-js/run-scan.ts index 841f16a20..a21540bf3 100644 --- a/packages/stats-generator/src/run-corejs-scan.ts +++ b/packages/stats-generator/src/benchmarks/core-js/run-scan.ts @@ -4,13 +4,11 @@ import { join, relative } from 'node:path' import { glob } from 'tinyglobby' import coreJsCompat from 'core-js-compat/compat.js' import getModulesListForTargetVersion from 'core-js-compat/get-modules-list-for-target-version.js' -import { packagesDir } from './constants.ts' -import { - benchmarkOutputPath, - getBenchmarkContext, - requireMeasurements, - writeJsonFile, -} from './utils.ts' +import { packagesDir } from '../../utils/paths.ts' +import { benchmarkOutputPath } from '../../utils/paths.ts' +import { writeJsonFile } from '../../utils/files.ts' + +import type { FrameworkConfig, TestConfig } from '../../types.ts' const BROWSER_TARGETS = 'last 2 Chrome major versions, last 2 Firefox major versions, last 2 Safari major versions, last 2 Edge major versions' @@ -41,12 +39,11 @@ function extractVersion(source: string): string { return match ? match[1] : 'unknown' } -async function main() { - const { packageName, framework, projectConfig } = await getBenchmarkContext({ - project: 'starter', - }) - requireMeasurements(framework, ['coreJS']) - +export async function runCoreJsScan( + packageName: string, + framework: FrameworkConfig, + projectConfig: TestConfig, +) { console.info( `Scanning build output for vendored core-js in ${framework.displayName} (${packageName})...\n`, ) @@ -131,8 +128,3 @@ async function main() { console.info(`\n✓ Saved core-js stats to ${outputPath}`) } - -main().catch((error) => { - console.error('Core-js scan failed:', error) - process.exit(1) -}) diff --git a/packages/stats-generator/src/dev-server-statistics.test.ts b/packages/stats-generator/src/benchmarks/dev-server/dev-server-statistics.test.ts similarity index 100% rename from packages/stats-generator/src/dev-server-statistics.test.ts rename to packages/stats-generator/src/benchmarks/dev-server/dev-server-statistics.test.ts diff --git a/packages/stats-generator/src/dev-server-statistics.ts b/packages/stats-generator/src/benchmarks/dev-server/dev-server-statistics.ts similarity index 87% rename from packages/stats-generator/src/dev-server-statistics.ts rename to packages/stats-generator/src/benchmarks/dev-server/dev-server-statistics.ts index cd5ebce81..b8b463d21 100644 --- a/packages/stats-generator/src/dev-server-statistics.ts +++ b/packages/stats-generator/src/benchmarks/dev-server/dev-server-statistics.ts @@ -1,4 +1,4 @@ -import { summarizeMetric } from './sample-statistics.ts' +import { summarizeMetric } from '../shared/sample-statistics.ts' import { DevServerStartupBenchmark } from '@framework-performance/results/benchmark-schemas' export function createDevServerStats(samples: number[]) { diff --git a/packages/stats-generator/src/dev-server.test.ts b/packages/stats-generator/src/benchmarks/dev-server/dev-server.test.ts similarity index 100% rename from packages/stats-generator/src/dev-server.test.ts rename to packages/stats-generator/src/benchmarks/dev-server/dev-server.test.ts diff --git a/packages/stats-generator/src/dev-server.ts b/packages/stats-generator/src/benchmarks/dev-server/dev-server.ts similarity index 100% rename from packages/stats-generator/src/dev-server.ts rename to packages/stats-generator/src/benchmarks/dev-server/dev-server.ts diff --git a/packages/stats-generator/src/run-dev-server-benchmark.ts b/packages/stats-generator/src/benchmarks/dev-server/run-benchmark.ts similarity index 85% rename from packages/stats-generator/src/run-dev-server-benchmark.ts rename to packages/stats-generator/src/benchmarks/dev-server/run-benchmark.ts index 141d1d443..7387334ea 100644 --- a/packages/stats-generator/src/run-dev-server-benchmark.ts +++ b/packages/stats-generator/src/benchmarks/dev-server/run-benchmark.ts @@ -1,9 +1,9 @@ -import { measurementsConfig } from './measurements.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' import { rmSync } from 'node:fs' import { tmpdir } from 'node:os' import { join } from 'node:path' -import { copyTrackedProject, installDependencies } from './benchmark-utils.ts' -import { packagesDir } from './constants.ts' +import { copyTrackedProject, installDependencies } from '../../utils/project.ts' +import { packagesDir } from '../../utils/paths.ts' import { advertisedPorts, isPortListening, @@ -12,14 +12,12 @@ import { waitForPortFree, type DevServerHandle, } from './dev-server.ts' -import { summarizeSamples } from './sample-statistics.ts' +import { summarizeSamples } from '../shared/sample-statistics.ts' import { createDevServerStats } from './dev-server-statistics.ts' -import { - benchmarkOutputPath, - getBenchmarkContext, - requireMeasurements, - writeJsonFile, -} from './utils.ts' +import { benchmarkOutputPath } from '../../utils/paths.ts' +import { writeJsonFile } from '../../utils/files.ts' + +import type { FrameworkConfig, TestConfig } from '../../types.ts' const READY_TIMEOUT_MS = 120_000 const PORT_FREE_TIMEOUT_MS = 10_000 @@ -94,18 +92,17 @@ async function measureStartTime( } } -async function main() { - const { packageName, framework, projectConfig } = await getBenchmarkContext({ - project: 'starter', - }) - requireMeasurements(framework, ['devServerStartUpDuration']) - +export async function runDevServerBenchmark( + packageName: string, + framework: FrameworkConfig, + projectConfig: TestConfig, +) { const runFrequency = measurementsConfig.devServer.runs const port = projectConfig.devServerPort if (port === undefined) { throw new Error( - `${packageName} has no devServerPort in packages/stats-generator/src/frameworks.ts`, + `${packageName} has no devServerPort in packages/results/src/frameworks-config.ts`, ) } @@ -161,8 +158,3 @@ async function main() { rmSync(tempDir, { recursive: true, force: true }) } } - -main().catch((error) => { - console.error('Dev server benchmark failed:', error) - process.exit(1) -}) diff --git a/packages/stats-generator/src/first-party-dependencies.test.ts b/packages/stats-generator/src/benchmarks/first-party-dependencies/first-party-dependencies.test.ts similarity index 98% rename from packages/stats-generator/src/first-party-dependencies.test.ts rename to packages/stats-generator/src/benchmarks/first-party-dependencies/first-party-dependencies.test.ts index f6741d2bc..d3f7d6150 100644 --- a/packages/stats-generator/src/first-party-dependencies.test.ts +++ b/packages/stats-generator/src/benchmarks/first-party-dependencies/first-party-dependencies.test.ts @@ -4,7 +4,7 @@ import { getFirstPartyDependencyStats, validateFirstPartyDependencyManifest, } from './first-party-dependencies.ts' -import { e18eStats } from './scripts/format-e18e-stats.ts' +import { e18eStats } from '../../scripts/format-e18e-stats.ts' test('derives starter dependency metrics from e18e output', () => { const stats = e18eStats.parse({ diff --git a/packages/stats-generator/src/first-party-dependencies.ts b/packages/stats-generator/src/benchmarks/first-party-dependencies/first-party-dependencies.ts similarity index 96% rename from packages/stats-generator/src/first-party-dependencies.ts rename to packages/stats-generator/src/benchmarks/first-party-dependencies/first-party-dependencies.ts index 34ea1c6b9..7f01db07c 100644 --- a/packages/stats-generator/src/first-party-dependencies.ts +++ b/packages/stats-generator/src/benchmarks/first-party-dependencies/first-party-dependencies.ts @@ -1,8 +1,9 @@ import { join } from 'node:path' import { parse } from 'yaml' -import { packagesDir } from './constants.ts' -import { getPackageJsonDeps, readJsonFile } from './utils.ts' -import type { PackageJson } from './types.ts' +import { packagesDir } from '../../utils/paths.ts' +import { getPackageJsonDeps } from '../../utils/package-metadata.ts' +import { readJsonFile } from '../../utils/files.ts' +import type { PackageJson } from '../../types.ts' type DependencySection = 'dependencies' | 'devDependencies' diff --git a/packages/stats-generator/src/run-first-party-dependency-scan.ts b/packages/stats-generator/src/benchmarks/first-party-dependencies/run-scan.ts similarity index 70% rename from packages/stats-generator/src/run-first-party-dependency-scan.ts rename to packages/stats-generator/src/benchmarks/first-party-dependencies/run-scan.ts index e0cd1d0d7..80d0d3483 100644 --- a/packages/stats-generator/src/run-first-party-dependency-scan.ts +++ b/packages/stats-generator/src/benchmarks/first-party-dependencies/run-scan.ts @@ -5,20 +5,11 @@ import { getFirstPartyDependencyManifest, getFirstPartyDependencyStats, } from './first-party-dependencies.ts' -import { packagesDir } from './constants.ts' -import { - benchmarkOutputPath, - getBenchmarkContext, - requireMeasurements, - writeJsonFile, -} from './utils.ts' - -async function main() { - const { packageName, framework } = await getBenchmarkContext({ - project: 'starter', - }) - requireMeasurements(framework, ['dependencyCounts']) +import { packagesDir } from '../../utils/paths.ts' +import { benchmarkOutputPath } from '../../utils/paths.ts' +import { writeJsonFile } from '../../utils/files.ts' +export async function runFirstPartyDependencyScan(packageName: string) { const manifest = getFirstPartyDependencyManifest(packageName) const outputPath = benchmarkOutputPath( packageName, @@ -42,8 +33,3 @@ async function main() { }) console.info(`Saved first-party dependency stats to ${outputPath}`) } - -main().catch((error) => { - console.error('First-party dependency scan failed:', error) - process.exit(1) -}) diff --git a/packages/stats-generator/src/run-framework-dependency-scan.ts b/packages/stats-generator/src/benchmarks/framework-dependencies/run-scan.ts similarity index 58% rename from packages/stats-generator/src/run-framework-dependency-scan.ts rename to packages/stats-generator/src/benchmarks/framework-dependencies/run-scan.ts index c546fbca4..bb0ef555b 100644 --- a/packages/stats-generator/src/run-framework-dependency-scan.ts +++ b/packages/stats-generator/src/benchmarks/framework-dependencies/run-scan.ts @@ -1,18 +1,14 @@ import { DependencyCountBenchmark } from '@framework-performance/results/benchmark-schemas' -import { - getFrameworkDependencyCountsFromPackageMetadata, - getBenchmarkContext, - requireMeasurements, - benchmarkOutputPath, - writeJsonFile, -} from './utils.ts' +import { getFrameworkDependencyCountsFromPackageMetadata } from '../../utils/package-metadata.ts' +import { benchmarkOutputPath } from '../../utils/paths.ts' +import { writeJsonFile } from '../../utils/files.ts' -async function main() { - const { packageName, framework } = await getBenchmarkContext({ - project: 'starter', - }) - requireMeasurements(framework, ['dependencyCounts']) +import type { FrameworkConfig } from '../../types.ts' +export async function runFrameworkDependencyScan( + packageName: string, + framework: FrameworkConfig, +) { const outputPath = benchmarkOutputPath( packageName, 'framework-dependency-stats.json', @@ -33,8 +29,3 @@ async function main() { }) console.info(`Saved framework dependency stats to ${outputPath}`) } - -main().catch((error) => { - console.error('Framework dependency scan failed:', error) - process.exit(1) -}) diff --git a/packages/stats-generator/src/initial-load-persistence.test.ts b/packages/stats-generator/src/benchmarks/initial-load/initial-load-persistence.test.ts similarity index 95% rename from packages/stats-generator/src/initial-load-persistence.test.ts rename to packages/stats-generator/src/benchmarks/initial-load/initial-load-persistence.test.ts index 91907f845..5e3461947 100644 --- a/packages/stats-generator/src/initial-load-persistence.test.ts +++ b/packages/stats-generator/src/benchmarks/initial-load/initial-load-persistence.test.ts @@ -5,8 +5,8 @@ import { join } from 'node:path' import { test } from 'node:test' import { InitialLoadResourceType } from '@framework-performance/results/benchmark-schemas' import { readBenchmarkResult } from '@framework-performance/results/storage' -import { frameworksConfig } from './frameworks.ts' -import { processCIStats } from './save-ci-stats.ts' +import { frameworksConfig } from '@framework-performance/results/frameworks-config' +import { processCIStats } from '../../scripts/save-ci-stats.ts' test('CI requires configured initial load results and validates complete measurements', async () => { const directory = mkdtempSync(join(tmpdir(), 'initial-load-ci-')) diff --git a/packages/stats-generator/src/initial-load.test.ts b/packages/stats-generator/src/benchmarks/initial-load/initial-load.test.ts similarity index 92% rename from packages/stats-generator/src/initial-load.test.ts rename to packages/stats-generator/src/benchmarks/initial-load/initial-load.test.ts index 2aa40f196..88a3fe0ba 100644 --- a/packages/stats-generator/src/initial-load.test.ts +++ b/packages/stats-generator/src/benchmarks/initial-load/initial-load.test.ts @@ -1,7 +1,7 @@ import assert from 'node:assert/strict' import { test } from 'node:test' import { InitialLoadResourceType } from '@framework-performance/results/benchmark-schemas' -import { parseResourceSummary } from './initialLoad/parse-resource-summary.ts' +import { parseResourceSummary } from './parse-resource-summary.ts' const items = InitialLoadResourceType.options.map((resourceType) => ({ resourceType, diff --git a/packages/stats-generator/src/initialLoad/parse-resource-summary.ts b/packages/stats-generator/src/benchmarks/initial-load/parse-resource-summary.ts similarity index 100% rename from packages/stats-generator/src/initialLoad/parse-resource-summary.ts rename to packages/stats-generator/src/benchmarks/initial-load/parse-resource-summary.ts diff --git a/packages/stats-generator/src/initialLoad/run-initial-load-benchmark.ts b/packages/stats-generator/src/benchmarks/initial-load/run-initial-load-benchmark.ts similarity index 88% rename from packages/stats-generator/src/initialLoad/run-initial-load-benchmark.ts rename to packages/stats-generator/src/benchmarks/initial-load/run-initial-load-benchmark.ts index 563f5a113..5c11955e7 100644 --- a/packages/stats-generator/src/initialLoad/run-initial-load-benchmark.ts +++ b/packages/stats-generator/src/benchmarks/initial-load/run-initial-load-benchmark.ts @@ -1,9 +1,9 @@ -import type { FrameworkConfig, TestConfig } from '../types.ts' -import { startBenchmarkServer } from '../benchmark-server.ts' -import { getHost } from '../serve/common.ts' +import type { FrameworkConfig, TestConfig } from '../../types.ts' +import { startBenchmarkServer } from '../../app-servers/benchmark-server.ts' +import { getHost } from '../../app-servers/common.ts' import puppeteer from 'puppeteer-core' -import { findChromium } from '../find-chromium.ts' +import { findChromium } from '../../utils/find-chromium.ts' import { parseResourceSummary } from './parse-resource-summary.ts' import { startFlow } from 'lighthouse' diff --git a/packages/stats-generator/src/run-install-benchmark.ts b/packages/stats-generator/src/benchmarks/install/run-benchmark.ts similarity index 86% rename from packages/stats-generator/src/run-install-benchmark.ts rename to packages/stats-generator/src/benchmarks/install/run-benchmark.ts index 23afc9742..40a2dcb7b 100644 --- a/packages/stats-generator/src/run-install-benchmark.ts +++ b/packages/stats-generator/src/benchmarks/install/run-benchmark.ts @@ -2,21 +2,18 @@ import { DependencyCountBenchmark, InstallBenchmark, } from '@framework-performance/results/benchmark-schemas' -import { measurementsConfig } from './measurements.ts' -import { summarizeMetric } from './sample-statistics.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import { summarizeMetric } from '../shared/sample-statistics.ts' import { execSync } from 'node:child_process' import { cpSync, mkdirSync, rmSync } from 'node:fs' import { basename, join } from 'node:path' import { tmpdir } from 'node:os' -import { installDependencies } from './benchmark-utils.ts' -import { packagesDir } from './constants.ts' -import { - getDirectorySize, - benchmarkOutputPath, - writeJsonFile, - getBenchmarkContext, - requireMeasurements, -} from './utils.ts' +import { installDependencies } from '../../utils/project.ts' +import { packagesDir } from '../../utils/paths.ts' +import { getDirectorySize, writeJsonFile } from '../../utils/files.ts' +import { benchmarkOutputPath } from '../../utils/paths.ts' + +import type { FrameworkConfig } from '../../types.ts' function execCommand(command: string, cwd: string): string { return execSync(command, { @@ -65,12 +62,10 @@ function getFrameworkVersion(cwd: string, frameworkPackage: string): string { } } -async function main() { - const { packageName, framework } = await getBenchmarkContext({ - project: 'starter', - }) - requireMeasurements(framework, ['installDuration', 'dependencyCounts']) - +export async function runInstallBenchmark( + packageName: string, + framework: FrameworkConfig, +) { const runFrequency = measurementsConfig.install.runs console.info( @@ -155,8 +150,3 @@ async function main() { rmSync(tempDir, { recursive: true, force: true }) } } - -main().catch((error) => { - console.error('Install benchmark failed:', error) - process.exit(1) -}) diff --git a/packages/stats-generator/src/node-engines.test.ts b/packages/stats-generator/src/benchmarks/node-engines/node-engines.test.ts similarity index 100% rename from packages/stats-generator/src/node-engines.test.ts rename to packages/stats-generator/src/benchmarks/node-engines/node-engines.test.ts diff --git a/packages/stats-generator/src/node-engines.ts b/packages/stats-generator/src/benchmarks/node-engines/node-engines.ts similarity index 100% rename from packages/stats-generator/src/node-engines.ts rename to packages/stats-generator/src/benchmarks/node-engines/node-engines.ts diff --git a/packages/stats-generator/src/run-node-engines-scan.ts b/packages/stats-generator/src/benchmarks/node-engines/run-scan.ts similarity index 91% rename from packages/stats-generator/src/run-node-engines-scan.ts rename to packages/stats-generator/src/benchmarks/node-engines/run-scan.ts index a2a253d37..c2086ff2c 100644 --- a/packages/stats-generator/src/run-node-engines-scan.ts +++ b/packages/stats-generator/src/benchmarks/node-engines/run-scan.ts @@ -1,16 +1,14 @@ import { MinimumNodeVersionBenchmark } from '@framework-performance/results/benchmark-schemas' import { lstatSync, readdirSync, readFileSync } from 'node:fs' import { join, relative } from 'node:path' -import { packagesDir } from './constants.ts' -import { - benchmarkOutputPath, - getBenchmarkContext, - requireMeasurements, - writeJsonFile, -} from './utils.ts' +import { packagesDir } from '../../utils/paths.ts' +import { benchmarkOutputPath } from '../../utils/paths.ts' +import { writeJsonFile } from '../../utils/files.ts' import { resolveMinimumNodeVersion } from './node-engines.ts' import type { NodeEngineEntry } from './node-engines.ts' +import type { FrameworkConfig } from '../../types.ts' + interface Manifest { name?: unknown version?: unknown @@ -102,12 +100,10 @@ function collectNestedPackageDirs(nodeModulesDir: string): string[] { return dirs } -async function main() { - const { packageName, framework } = await getBenchmarkContext({ - project: 'starter', - }) - requireMeasurements(framework, ['minimumNodeVersion']) - +export async function runNodeEnginesScan( + packageName: string, + framework: FrameworkConfig, +) { console.info( `Scanning installed dependencies for engines.node in ${framework.displayName} (${packageName})...\n`, ) @@ -190,8 +186,3 @@ async function main() { console.info(`\n✓ Saved Node engines stats to ${outputPath}`) } - -main().catch((error) => { - console.error('Node engines scan failed:', error) - process.exit(1) -}) diff --git a/packages/stats-generator/src/serverSideRendered/index.ts b/packages/stats-generator/src/benchmarks/server-side-rendered/index.ts similarity index 81% rename from packages/stats-generator/src/serverSideRendered/index.ts rename to packages/stats-generator/src/benchmarks/server-side-rendered/index.ts index 74f3399ae..22a677f34 100644 --- a/packages/stats-generator/src/serverSideRendered/index.ts +++ b/packages/stats-generator/src/benchmarks/server-side-rendered/index.ts @@ -1,7 +1,7 @@ -import { measurementsConfig } from '../measurements.ts' -import type { FrameworkConfig, TestConfig } from '../types.ts' -import { startBenchmarkServer } from '../benchmark-server.ts' -import { getHost } from '../serve/common.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import type { FrameworkConfig, TestConfig } from '../../types.ts' +import { startBenchmarkServer } from '../../app-servers/benchmark-server.ts' +import { getHost } from '../../app-servers/common.ts' import { runBenchmark } from './run-benchmark.ts' import type { ServerSideRenderedBenchmarkResult } from './types.ts' diff --git a/packages/stats-generator/src/serverSideRendered/run-benchmark.ts b/packages/stats-generator/src/benchmarks/server-side-rendered/run-benchmark.ts similarity index 93% rename from packages/stats-generator/src/serverSideRendered/run-benchmark.ts rename to packages/stats-generator/src/benchmarks/server-side-rendered/run-benchmark.ts index 177f38926..2d0edc1c7 100644 --- a/packages/stats-generator/src/serverSideRendered/run-benchmark.ts +++ b/packages/stats-generator/src/benchmarks/server-side-rendered/run-benchmark.ts @@ -1,19 +1,19 @@ -import { findChromium } from '../find-chromium.ts' +import { findChromium } from '../../utils/find-chromium.ts' import puppeteer from 'puppeteer-core' import { startFlow } from 'lighthouse' -import { warmUpServer } from '../server-warmup.ts' +import { warmUpServer } from '../../app-servers/server-warmup.ts' import { getInteractionTimingFromLighthouse, getNavigationInteractionTimingFromLighthouse, prepareInteractionTraceForLighthouse, -} from '../interaction-timing.ts' -import { getInteractionWorkFromTrace } from '../interaction-work.ts' +} from '../shared/interaction-timing.ts' +import { getInteractionWorkFromTrace } from '../shared/interaction-work.ts' import type { ServerSideRenderedBenchmarkResult, ServerSideRenderedRunResult, } from './types.ts' -import { assembleServerRendering } from '../server-rendering.ts' -import { measurementsConfig } from '../measurements.ts' +import { assembleServerRendering } from './server-rendering.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' const SERVER_SIDE_RENDERED_PATH = measurementsConfig.ssrLighthouse.path diff --git a/packages/stats-generator/src/server-rendering.test.ts b/packages/stats-generator/src/benchmarks/server-side-rendered/server-rendering.test.ts similarity index 97% rename from packages/stats-generator/src/server-rendering.test.ts rename to packages/stats-generator/src/benchmarks/server-side-rendered/server-rendering.test.ts index 8dc03a30f..855f0ef63 100644 --- a/packages/stats-generator/src/server-rendering.test.ts +++ b/packages/stats-generator/src/benchmarks/server-side-rendered/server-rendering.test.ts @@ -2,7 +2,7 @@ import { test } from 'node:test' import assert from 'node:assert/strict' import { assembleServerRendering } from './server-rendering.ts' import { SSRLighthouseBenchmark } from '@framework-performance/results/benchmark-schemas' -import { measuredSSRLighthouse } from './rendered-sample-metrics.ts' +import { measuredSSRLighthouse } from '../shared/rendered-sample-metrics.ts' test('assembles server rendering from exact raw browser measurements', () => { const iterations = [1, 3].map((value) => ({ diff --git a/packages/stats-generator/src/server-rendering.ts b/packages/stats-generator/src/benchmarks/server-side-rendered/server-rendering.ts similarity index 88% rename from packages/stats-generator/src/server-rendering.ts rename to packages/stats-generator/src/benchmarks/server-side-rendered/server-rendering.ts index 4d24cdb4e..6a9cd9120 100644 --- a/packages/stats-generator/src/server-rendering.ts +++ b/packages/stats-generator/src/benchmarks/server-side-rendered/server-rendering.ts @@ -1,9 +1,9 @@ import { renderedSampleMetrics, measuredSSRLighthouse, -} from './rendered-sample-metrics.ts' -import { summarizeMetric } from './sample-statistics.ts' -import type { RenderedTestSample } from './types.ts' +} from '../shared/rendered-sample-metrics.ts' +import { summarizeMetric } from '../shared/sample-statistics.ts' +import type { RenderedTestSample } from '../../types.ts' export function assembleServerRendering(iterations: RenderedTestSample[]) { return measuredSSRLighthouse.parse({ diff --git a/packages/stats-generator/src/serverSideRendered/types.ts b/packages/stats-generator/src/benchmarks/server-side-rendered/types.ts similarity index 79% rename from packages/stats-generator/src/serverSideRendered/types.ts rename to packages/stats-generator/src/benchmarks/server-side-rendered/types.ts index cf32888ad..57f3e18da 100644 --- a/packages/stats-generator/src/serverSideRendered/types.ts +++ b/packages/stats-generator/src/benchmarks/server-side-rendered/types.ts @@ -1,7 +1,7 @@ import type { z } from 'zod' import type { SSRLighthouseBenchmark } from '@framework-performance/results/benchmark-schemas' -import type { InteractionTiming } from '../types.ts' -import type { InteractionWork } from '../interaction-work.ts' +import type { InteractionTiming } from '../../types.ts' +import type { InteractionWork } from '../shared/interaction-work.ts' export interface ServerSideRenderedRunResult { firstPaint: number | null firstContentfulPaint: number | null diff --git a/packages/stats-generator/src/baseline-html.ts b/packages/stats-generator/src/benchmarks/shared/baseline-html.ts similarity index 92% rename from packages/stats-generator/src/baseline-html.ts rename to packages/stats-generator/src/benchmarks/shared/baseline-html.ts index 25f7bdc1d..36e11b7e2 100644 --- a/packages/stats-generator/src/baseline-html.ts +++ b/packages/stats-generator/src/benchmarks/shared/baseline-html.ts @@ -1,4 +1,4 @@ -import type { TableEntry } from '../../testdata/src/ssr.ts' +import type { TableEntry } from '../../../../testdata/src/ssr.ts' export function renderSSRThroughputHtml(entries: TableEntry[]): string { const rows = entries diff --git a/packages/stats-generator/src/interaction-timing.test.ts b/packages/stats-generator/src/benchmarks/shared/interaction-timing.test.ts similarity index 100% rename from packages/stats-generator/src/interaction-timing.test.ts rename to packages/stats-generator/src/benchmarks/shared/interaction-timing.test.ts diff --git a/packages/stats-generator/src/interaction-timing.ts b/packages/stats-generator/src/benchmarks/shared/interaction-timing.ts similarity index 98% rename from packages/stats-generator/src/interaction-timing.ts rename to packages/stats-generator/src/benchmarks/shared/interaction-timing.ts index dfd01e573..64817b650 100644 --- a/packages/stats-generator/src/interaction-timing.ts +++ b/packages/stats-generator/src/benchmarks/shared/interaction-timing.ts @@ -1,6 +1,6 @@ import { NavigationInsights } from 'lighthouse/core/computed/navigation-insights.js' import type { Artifacts, Result } from 'lighthouse' -import type { InteractionTiming } from './types.ts' +import type { InteractionTiming } from '../../types.ts' interface LighthouseAudit { details?: unknown diff --git a/packages/stats-generator/src/interaction-work.test.ts b/packages/stats-generator/src/benchmarks/shared/interaction-work.test.ts similarity index 100% rename from packages/stats-generator/src/interaction-work.test.ts rename to packages/stats-generator/src/benchmarks/shared/interaction-work.test.ts diff --git a/packages/stats-generator/src/interaction-work.ts b/packages/stats-generator/src/benchmarks/shared/interaction-work.ts similarity index 100% rename from packages/stats-generator/src/interaction-work.ts rename to packages/stats-generator/src/benchmarks/shared/interaction-work.ts diff --git a/packages/stats-generator/src/rendered-sample-metrics.ts b/packages/stats-generator/src/benchmarks/shared/rendered-sample-metrics.ts similarity index 96% rename from packages/stats-generator/src/rendered-sample-metrics.ts rename to packages/stats-generator/src/benchmarks/shared/rendered-sample-metrics.ts index e551f8f59..a580f2d38 100644 --- a/packages/stats-generator/src/rendered-sample-metrics.ts +++ b/packages/stats-generator/src/benchmarks/shared/rendered-sample-metrics.ts @@ -2,7 +2,7 @@ import { CSRLighthouseBenchmark, SSRLighthouseBenchmark, } from '@framework-performance/results/benchmark-schemas' -import type { RenderedTestSample } from './types.ts' +import type { RenderedTestSample } from '../../types.ts' export function renderedSampleMetrics(sample: RenderedTestSample) { const timing = sample.interactionTests diff --git a/packages/stats-generator/src/sample-statistics.test.ts b/packages/stats-generator/src/benchmarks/shared/sample-statistics.test.ts similarity index 100% rename from packages/stats-generator/src/sample-statistics.test.ts rename to packages/stats-generator/src/benchmarks/shared/sample-statistics.test.ts diff --git a/packages/stats-generator/src/sample-statistics.ts b/packages/stats-generator/src/benchmarks/shared/sample-statistics.ts similarity index 97% rename from packages/stats-generator/src/sample-statistics.ts rename to packages/stats-generator/src/benchmarks/shared/sample-statistics.ts index 9add425dc..2b2b3ef82 100644 --- a/packages/stats-generator/src/sample-statistics.ts +++ b/packages/stats-generator/src/benchmarks/shared/sample-statistics.ts @@ -1,6 +1,6 @@ import type { IterationSummary } from '@framework-performance/results/benchmark-schemas' import type { z } from 'zod' -import type { TimeStat } from './types.ts' +import type { TimeStat } from '../../types.ts' function round(value: number, decimalPlaces: number): number { const factor = 10 ** decimalPlaces diff --git a/packages/stats-generator/src/ssrLoad/config.ts b/packages/stats-generator/src/benchmarks/ssr-load/config.ts similarity index 84% rename from packages/stats-generator/src/ssrLoad/config.ts rename to packages/stats-generator/src/benchmarks/ssr-load/config.ts index 7aefe2c36..3a4d0cd82 100644 --- a/packages/stats-generator/src/ssrLoad/config.ts +++ b/packages/stats-generator/src/benchmarks/ssr-load/config.ts @@ -1,5 +1,5 @@ -import type { FrameworkConfig } from '../types.ts' -import { measurementsConfig } from '../measurements.ts' +import type { FrameworkConfig } from '../../types.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' export type SSRLoadKind = 'ssrLoad' | 'ssrLoadRouterLinks' diff --git a/packages/stats-generator/src/ssrLoad/index.ts b/packages/stats-generator/src/benchmarks/ssr-load/index.ts similarity index 93% rename from packages/stats-generator/src/ssrLoad/index.ts rename to packages/stats-generator/src/benchmarks/ssr-load/index.ts index b3ece8cdb..df03a7722 100644 --- a/packages/stats-generator/src/ssrLoad/index.ts +++ b/packages/stats-generator/src/benchmarks/ssr-load/index.ts @@ -1,9 +1,9 @@ import { spawn } from 'node:child_process' import { join } from 'node:path' import { fileURLToPath } from 'node:url' -import { packagesDir } from '../constants.ts' -import type { FrameworkConfig, TestConfig } from '../types.ts' -import { getHost, getPort } from '../serve/common.ts' +import { packagesDir } from '../../utils/paths.ts' +import type { FrameworkConfig, TestConfig } from '../../types.ts' +import { getHost, getPort } from '../../app-servers/common.ts' import { runLoadTest } from './run-load-test.ts' import type { SSRLoadBenchmarkResult } from './types.ts' @@ -47,7 +47,7 @@ async function spawnServer( const port = getPort(DEFAULT_SSR_LOAD_PORT) const appDir = join(packagesDir, packageName) const scriptPath = fileURLToPath( - new URL(`../serve/${serveScript}`, import.meta.url), + new URL(`../../app-servers/${serveScript}`, import.meta.url), ) const proc = spawn('node', [scriptPath, appDir], { diff --git a/packages/stats-generator/src/ssrLoad/run-load-test.ts b/packages/stats-generator/src/benchmarks/ssr-load/run-load-test.ts similarity index 97% rename from packages/stats-generator/src/ssrLoad/run-load-test.ts rename to packages/stats-generator/src/benchmarks/ssr-load/run-load-test.ts index e91c111ce..9ca2bff00 100644 --- a/packages/stats-generator/src/ssrLoad/run-load-test.ts +++ b/packages/stats-generator/src/benchmarks/ssr-load/run-load-test.ts @@ -1,5 +1,5 @@ import { SSRLoadStageOptions } from '@framework-performance/results/benchmark-types' -import { measurementsConfig } from '../measurements.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' import { getLoadPeakStage, selectRepresentativeIteration, @@ -8,7 +8,7 @@ import { SSRLoadBenchmark, SSRLoadRouterLinksBenchmark, } from '@framework-performance/results/benchmark-schemas' -import { summarizeMetric } from '../sample-statistics.ts' +import { summarizeMetric } from '../shared/sample-statistics.ts' import { getSSRLoadKind, type SSRLoadKind } from './config.ts' import { setTimeout as delay } from 'node:timers/promises' import autocannon from 'autocannon' diff --git a/packages/stats-generator/src/ssr-load.test.ts b/packages/stats-generator/src/benchmarks/ssr-load/ssr-load.test.ts similarity index 96% rename from packages/stats-generator/src/ssr-load.test.ts rename to packages/stats-generator/src/benchmarks/ssr-load/ssr-load.test.ts index d82a47c58..fd37ed9bc 100644 --- a/packages/stats-generator/src/ssr-load.test.ts +++ b/packages/stats-generator/src/benchmarks/ssr-load/ssr-load.test.ts @@ -1,4 +1,4 @@ -import { frameworksConfig } from './frameworks.ts' +import { frameworksConfig } from '@framework-performance/results/frameworks-config' import { SSRLoadBenchmark, SSRLoadRouterLinksBenchmark, @@ -7,17 +7,17 @@ import { readFileSync } from 'node:fs' import { getLoadPeakStage } from '@framework-performance/results/selection' import assert from 'node:assert/strict' import { test } from 'node:test' -import { getSSRLoadPath } from './ssrLoad/config.ts' -import { verifySSRLoadTable } from './ssrLoad/verify-table.ts' -import { renderBaselineHtml } from './baseline-html.ts' +import { getSSRLoadPath } from './config.ts' +import { verifySSRLoadTable } from './verify-table.ts' +import { renderBaselineHtml } from '../shared/baseline-html.ts' import { measureLoadStage, runLoadTest, summarizeBenchmarkSweeps, -} from './ssrLoad/run-load-test.ts' -import type { SSRLoadStageStats } from './ssrLoad/types.ts' -import { testData } from '../../testdata/src/ssr.ts' -import { measurementsConfig } from './measurements.ts' +} from './run-load-test.ts' +import type { SSRLoadStageStats } from './types.ts' +import { testData } from '../../../../testdata/src/ssr.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' function loadStage( overrides: Partial[0]> = {}, @@ -143,7 +143,7 @@ test('HTTP table verification rejects missing rows, wrong columns, text, and des }) const readRouteSource = (path: string) => - readFileSync(new URL(`../../${path}`, import.meta.url), 'utf8') + readFileSync(new URL(`../../../../${path}`, import.meta.url), 'utf8') const compact = (source: string) => source.replace(/\s+/g, '') test('Next.js SSR routes load the same data and render equivalent client tables', () => { diff --git a/packages/stats-generator/src/ssrLoad/types.ts b/packages/stats-generator/src/benchmarks/ssr-load/types.ts similarity index 100% rename from packages/stats-generator/src/ssrLoad/types.ts rename to packages/stats-generator/src/benchmarks/ssr-load/types.ts diff --git a/packages/stats-generator/src/verify-ssr-load.ts b/packages/stats-generator/src/benchmarks/ssr-load/verify-ssr-load.ts similarity index 78% rename from packages/stats-generator/src/verify-ssr-load.ts rename to packages/stats-generator/src/benchmarks/ssr-load/verify-ssr-load.ts index 65c2bdf8d..7dd3d7664 100644 --- a/packages/stats-generator/src/verify-ssr-load.ts +++ b/packages/stats-generator/src/benchmarks/ssr-load/verify-ssr-load.ts @@ -1,14 +1,18 @@ -import { getFrameworks } from './get-frameworks.ts' -import { startSSRLoadServer } from './ssrLoad/index.ts' -import { getSSRLoadPath } from './ssrLoad/config.ts' -import { verifySSRLoadTable } from './ssrLoad/verify-table.ts' +import { + frameworksConfig, + type FrameworkConfig, +} from '@framework-performance/results/frameworks-config' +import { startSSRLoadServer } from './index.ts' +import { getSSRLoadPath } from './config.ts' +import { verifySSRLoadTable } from './verify-table.ts' // Validate production builds without measuring or writing benchmark results. process.env.HOST = '127.0.0.1' process.env.PORT = '3003' process.env.SSR_LOAD_KIND = 'ssrLoad' const selected = process.argv.slice(2) -for (const framework of await getFrameworks()) { +const frameworks: FrameworkConfig[] = frameworksConfig +for (const framework of frameworks) { const { app, measurements } = framework if (!app || !measurements.includes('ssrLoad')) continue if (selected.length && !selected.includes(framework.name)) continue diff --git a/packages/stats-generator/src/ssrLoad/verify-table.ts b/packages/stats-generator/src/benchmarks/ssr-load/verify-table.ts similarity index 100% rename from packages/stats-generator/src/ssrLoad/verify-table.ts rename to packages/stats-generator/src/benchmarks/ssr-load/verify-table.ts diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/astro.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/astro.ts similarity index 93% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/astro.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/astro.ts index b2eca9969..9173dc81f 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/astro.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/astro.ts @@ -1,6 +1,6 @@ import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import type { ServerRenderHandler } from '../types.ts' export async function buildHandler(): Promise { diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/baseline-html.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/baseline-html.ts similarity index 74% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/baseline-html.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/baseline-html.ts index c2466cdde..9e2896ba7 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/baseline-html.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/baseline-html.ts @@ -1,5 +1,5 @@ -import { testData } from '../../../../testdata/src/ssr.ts' -import { renderSSRThroughputHtml } from '../../baseline-html.ts' +import { testData } from '../../../../../testdata/src/ssr.ts' +import { renderSSRThroughputHtml } from '../../shared/baseline-html.ts' import type { NodeServerRenderHandler, ServerRenderHandler } from '../types.ts' export async function buildHandler(): Promise { diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/nextjs.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/nextjs.ts similarity index 92% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/nextjs.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/nextjs.ts index f5586aaa8..b68a8545b 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/nextjs.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/nextjs.ts @@ -1,6 +1,6 @@ import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import type { NodeServerRenderHandler, ServerRenderHandler } from '../types.ts' export async function buildHandler(): Promise { diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/nitro.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/nitro.ts similarity index 100% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/nitro.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/nitro.ts diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/nuxt.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/nuxt.ts similarity index 88% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/nuxt.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/nuxt.ts index 175b660f1..e73fd8a82 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/nuxt.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/nuxt.ts @@ -1,6 +1,6 @@ import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import type { ServerRenderHandler } from '../types.ts' export async function buildHandler(): Promise { diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/pracht.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/pracht.ts similarity index 91% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/pracht.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/pracht.ts index 8b7fda1ef..0bb224b68 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/pracht.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/pracht.ts @@ -1,6 +1,6 @@ import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import type { ServerRenderHandler } from '../types.ts' export async function buildHandler(): Promise { diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/react-router.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/react-router.ts similarity index 93% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/react-router.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/react-router.ts index da53a6d94..e254fd3a7 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/react-router.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/react-router.ts @@ -1,7 +1,7 @@ import { createRequire } from 'node:module' import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import type { ServerRenderHandler } from '../types.ts' export async function buildHandler(): Promise { diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/solid-start.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/solid-start.ts similarity index 94% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/solid-start.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/solid-start.ts index 80a31cc39..fe0ca0d82 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/solid-start.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/solid-start.ts @@ -1,6 +1,6 @@ import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import { importWithoutListening } from './nitro.ts' import type { ServerRenderHandler } from '../types.ts' diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/solid.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/solid.ts similarity index 90% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/solid.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/solid.ts index 2a054cf00..bb533ee7e 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/solid.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/solid.ts @@ -1,6 +1,6 @@ import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import type { ServerRenderHandler } from '../types.ts' export async function buildHandler(): Promise { diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/sveltekit.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/sveltekit.ts similarity index 88% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/sveltekit.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/sveltekit.ts index 7a0a9a8fb..a756d6b3f 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/sveltekit.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/sveltekit.ts @@ -1,6 +1,6 @@ import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import type { ServerRenderHandler } from '../types.ts' export async function buildHandler(): Promise { diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/tanstack-start.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/tanstack-start.ts similarity index 94% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/tanstack-start.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/tanstack-start.ts index f08f567ae..a4894c114 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/tanstack-start.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/tanstack-start.ts @@ -1,6 +1,6 @@ import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import { importWithoutListening } from './nitro.ts' import type { ServerRenderHandler } from '../types.ts' diff --git a/packages/stats-generator/src/ssrRequestThroughput/handlers/void.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/void.ts similarity index 88% rename from packages/stats-generator/src/ssrRequestThroughput/handlers/void.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/void.ts index 09c9eff38..02ec923a5 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/handlers/void.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/handlers/void.ts @@ -1,6 +1,6 @@ import { join } from 'node:path' import { pathToFileURL } from 'node:url' -import { packagesDir } from '../../constants.ts' +import { packagesDir } from '../../../utils/paths.ts' import type { ServerRenderHandler } from '../types.ts' export async function buildHandler(): Promise { diff --git a/packages/stats-generator/src/ssrRequestThroughput/index.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/index.ts similarity index 97% rename from packages/stats-generator/src/ssrRequestThroughput/index.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/index.ts index 4c16820d2..f5a84ee6b 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/index.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/index.ts @@ -10,7 +10,7 @@ import { buildHandler as buildSolidHandler } from './handlers/solid.ts' import { buildHandler as buildSveltekitHandler } from './handlers/sveltekit.ts' import { buildHandler as buildTanstackStartHandler } from './handlers/tanstack-start.ts' import { buildHandler as buildVoidHandler } from './handlers/void.ts' -import type { FrameworkConfig, TestConfig } from '../types.ts' +import type { FrameworkConfig, TestConfig } from '../../types.ts' import type { ServerRenderHandler, SSRRequestThroughputBenchmarkResult, diff --git a/packages/stats-generator/src/ssrRequestThroughput/mock-http.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/mock-http.ts similarity index 100% rename from packages/stats-generator/src/ssrRequestThroughput/mock-http.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/mock-http.ts diff --git a/packages/stats-generator/src/request-throughput.test.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/request-throughput.test.ts similarity index 100% rename from packages/stats-generator/src/request-throughput.test.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/request-throughput.test.ts diff --git a/packages/stats-generator/src/request-throughput.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/request-throughput.ts similarity index 96% rename from packages/stats-generator/src/request-throughput.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/request-throughput.ts index 124dcb61c..24e478561 100644 --- a/packages/stats-generator/src/request-throughput.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/request-throughput.ts @@ -1,6 +1,6 @@ import type { z } from 'zod' import { SSRThroughputBenchmark } from '@framework-performance/results/benchmark-schemas' -import { summarizeMetric } from './sample-statistics.ts' +import { summarizeMetric } from '../shared/sample-statistics.ts' export type RequestThroughputIteration = z.infer< typeof SSRThroughputBenchmark diff --git a/packages/stats-generator/src/ssrRequestThroughput/run-benchmark.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/run-benchmark.ts similarity index 96% rename from packages/stats-generator/src/ssrRequestThroughput/run-benchmark.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/run-benchmark.ts index e04ae6144..ca8e74c2e 100644 --- a/packages/stats-generator/src/ssrRequestThroughput/run-benchmark.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/run-benchmark.ts @@ -1,9 +1,9 @@ -import { measurementsConfig } from '../measurements.ts' -import type { RequestThroughputIteration } from '../request-throughput.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import type { RequestThroughputIteration } from './request-throughput.ts' import { assembleRequestThroughput, createRequestThroughputIteration, -} from '../request-throughput.ts' +} from './request-throughput.ts' import { Bench } from 'tinybench' import { IncomingMessage, ServerResponse } from './mock-http.ts' import type { diff --git a/packages/stats-generator/src/ssr-request-throughput.test.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/ssr-request-throughput.test.ts similarity index 93% rename from packages/stats-generator/src/ssr-request-throughput.test.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/ssr-request-throughput.test.ts index 3b2934c97..bc5a96cb8 100644 --- a/packages/stats-generator/src/ssr-request-throughput.test.ts +++ b/packages/stats-generator/src/benchmarks/ssr-request-throughput/ssr-request-throughput.test.ts @@ -1,11 +1,8 @@ import assert from 'node:assert/strict' import { once } from 'node:events' import test from 'node:test' -import { - IncomingMessage, - ServerResponse, -} from './ssrRequestThroughput/mock-http.ts' -import { consumeWebResponse } from './ssrRequestThroughput/run-benchmark.ts' +import { IncomingMessage, ServerResponse } from './mock-http.ts' +import { consumeWebResponse } from './run-benchmark.ts' test('timed Web responses drain every chunk without collecting the body', async () => { const chunks = [new Uint8Array([1, 2]), new Uint8Array([3, 4, 5])] diff --git a/packages/stats-generator/src/ssrRequestThroughput/types.ts b/packages/stats-generator/src/benchmarks/ssr-request-throughput/types.ts similarity index 100% rename from packages/stats-generator/src/ssrRequestThroughput/types.ts rename to packages/stats-generator/src/benchmarks/ssr-request-throughput/types.ts diff --git a/packages/stats-generator/src/constants.ts b/packages/stats-generator/src/constants.ts deleted file mode 100644 index cb1610226..000000000 --- a/packages/stats-generator/src/constants.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { dirname, join } from 'node:path' -import { fileURLToPath } from 'node:url' - -const __filename = fileURLToPath(import.meta.url) -const __dirname = dirname(__filename) - -export const packagesDir = join(__dirname, '../..') diff --git a/packages/stats-generator/src/frameworks.ts b/packages/stats-generator/src/frameworks.ts deleted file mode 100644 index c12f10c5c..000000000 --- a/packages/stats-generator/src/frameworks.ts +++ /dev/null @@ -1 +0,0 @@ -export { frameworksConfig } from '@framework-performance/results/frameworks-config' diff --git a/packages/stats-generator/src/get-frameworks.ts b/packages/stats-generator/src/get-frameworks.ts deleted file mode 100644 index c23106898..000000000 --- a/packages/stats-generator/src/get-frameworks.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { frameworksConfig } from './frameworks.ts' -import type { FrameworkConfig } from './types.ts' - -export async function getFrameworks(): Promise { - return frameworksConfig -} diff --git a/packages/stats-generator/src/measurements.ts b/packages/stats-generator/src/measurements.ts deleted file mode 100644 index 4ae5e262f..000000000 --- a/packages/stats-generator/src/measurements.ts +++ /dev/null @@ -1 +0,0 @@ -export { measurementsConfig } from '@framework-performance/results/measurements-config' diff --git a/packages/stats-generator/src/print-frameworks.ts b/packages/stats-generator/src/print-frameworks.ts deleted file mode 100644 index 8f43ec269..000000000 --- a/packages/stats-generator/src/print-frameworks.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { frameworksConfig } from './frameworks.ts' - -process.stdout.write(JSON.stringify(frameworksConfig)) diff --git a/packages/stats-generator/src/run-benchmarks-scripts/run-browser-baseline-scan.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-browser-baseline-scan.ts new file mode 100644 index 000000000..e70dadc12 --- /dev/null +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-browser-baseline-scan.ts @@ -0,0 +1,18 @@ +import { runBrowserBaselineScan } from '../benchmarks/browser-baseline/run-scan.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' + +async function main() { + const { packageName, projectConfig, framework } = await getBenchmarkContext({ + project: 'starter', + }) + requireMeasurements(framework, ['browserBaseline']) + await runBrowserBaselineScan(packageName, projectConfig) +} + +main().catch((error) => { + console.error('Browser baseline scan failed:', error) + process.exit(1) +}) diff --git a/packages/stats-generator/src/run-benchmarks-scripts/run-build-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-build-benchmark.ts new file mode 100644 index 000000000..ae9462ce1 --- /dev/null +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-build-benchmark.ts @@ -0,0 +1,18 @@ +import { runBuildBenchmark } from '../benchmarks/build/run-benchmark.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' + +async function main() { + const { packageName, framework, projectConfig } = await getBenchmarkContext({ + project: 'starter', + }) + requireMeasurements(framework, ['buildDuration', 'coreJS', 'browserBaseline']) + await runBuildBenchmark(packageName, framework, projectConfig) +} + +main().catch((error) => { + console.error('Build benchmark failed:', error) + process.exit(1) +}) diff --git a/packages/stats-generator/src/run-client-side-rendered-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-client-side-rendered-benchmark.ts similarity index 82% rename from packages/stats-generator/src/run-client-side-rendered-benchmark.ts rename to packages/stats-generator/src/run-benchmarks-scripts/run-client-side-rendered-benchmark.ts index b5ea52ddd..9a7b6c9a9 100644 --- a/packages/stats-generator/src/run-client-side-rendered-benchmark.ts +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-client-side-rendered-benchmark.ts @@ -1,11 +1,11 @@ -import { measurementsConfig } from './measurements.ts' -import { runClientSideRenderedBenchmark } from './clientSideRendered/index.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import { runClientSideRenderedBenchmark } from '../benchmarks/client-side-rendered/index.ts' +import { benchmarkOutputPath } from '../utils/paths.ts' import { - benchmarkOutputPath, getBenchmarkContext, requireMeasurements, - writeJsonFile, -} from './utils.ts' +} from '../utils/benchmark-context.ts' +import { writeJsonFile } from '../utils/files.ts' async function main() { const { packageName, framework, projectConfig, frameworkVersion } = diff --git a/packages/stats-generator/src/run-containerized-ssr-load.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-containerized-ssr-load.ts similarity index 89% rename from packages/stats-generator/src/run-containerized-ssr-load.ts rename to packages/stats-generator/src/run-benchmarks-scripts/run-containerized-ssr-load.ts index e5817d4e4..ac9de0b64 100644 --- a/packages/stats-generator/src/run-containerized-ssr-load.ts +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-containerized-ssr-load.ts @@ -1,15 +1,21 @@ -import { getSSRLoadKind, getSSRLoadPath } from './ssrLoad/config.ts' +import { + getSSRLoadKind, + getSSRLoadPath, +} from '../benchmarks/ssr-load/config.ts' import { spawn } from 'node:child_process' import { readFileSync } from 'node:fs' import { cwd, env, exit, getgid, getuid, pid } from 'node:process' -import { getBenchmarkContext, requireMeasurements } from './utils.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' const RUN_SUFFIX = `${env.GITHUB_RUN_ID ?? 'local'}-${pid}` const NETWORK_NAME = `framework-performance-ssr-load-${RUN_SUFFIX}` const SERVER_NAME = `framework-performance-ssr-load-server-${RUN_SUFFIX}` const LOAD_GENERATOR_NAME = `framework-performance-ssr-load-generator-${RUN_SUFFIX}` const nodeVersion = readFileSync( - new URL('../../../.nvmrc', import.meta.url), + new URL('../../../../.nvmrc', import.meta.url), 'utf8', ).trim() const NODE_IMAGE = `node:${nodeVersion}-bookworm-slim` @@ -102,7 +108,7 @@ async function main() { `SSR_LOAD_KIND=${kind}`, NODE_IMAGE, 'node', - 'packages/stats-generator/src/run-ssr-load-server.ts', + 'packages/stats-generator/src/run-benchmarks-scripts/run-ssr-load-server.ts', framework.name, ]) @@ -128,7 +134,7 @@ async function main() { `SSR_LOAD_KIND=${kind}`, NODE_IMAGE, 'node', - 'packages/stats-generator/src/run-ssr-load-benchmark.ts', + 'packages/stats-generator/src/run-benchmarks-scripts/run-ssr-load-benchmark.ts', framework.name, ]) succeeded = true diff --git a/packages/stats-generator/src/run-benchmarks-scripts/run-corejs-scan.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-corejs-scan.ts new file mode 100644 index 000000000..4096f3270 --- /dev/null +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-corejs-scan.ts @@ -0,0 +1,18 @@ +import { runCoreJsScan } from '../benchmarks/core-js/run-scan.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' + +async function main() { + const { packageName, framework, projectConfig } = await getBenchmarkContext({ + project: 'starter', + }) + requireMeasurements(framework, ['coreJS']) + await runCoreJsScan(packageName, framework, projectConfig) +} + +main().catch((error) => { + console.error('Core-js scan failed:', error) + process.exit(1) +}) diff --git a/packages/stats-generator/src/run-benchmarks-scripts/run-dev-server-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-dev-server-benchmark.ts new file mode 100644 index 000000000..e8e623d0e --- /dev/null +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-dev-server-benchmark.ts @@ -0,0 +1,18 @@ +import { runDevServerBenchmark } from '../benchmarks/dev-server/run-benchmark.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' + +async function main() { + const { packageName, framework, projectConfig } = await getBenchmarkContext({ + project: 'starter', + }) + requireMeasurements(framework, ['devServerStartUpDuration']) + await runDevServerBenchmark(packageName, framework, projectConfig) +} + +main().catch((error) => { + console.error('Dev server benchmark failed:', error) + process.exit(1) +}) diff --git a/packages/stats-generator/src/run-benchmarks-scripts/run-first-party-dependency-scan.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-first-party-dependency-scan.ts new file mode 100644 index 000000000..027490319 --- /dev/null +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-first-party-dependency-scan.ts @@ -0,0 +1,18 @@ +import { runFirstPartyDependencyScan } from '../benchmarks/first-party-dependencies/run-scan.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' + +async function main() { + const { packageName, framework } = await getBenchmarkContext({ + project: 'starter', + }) + requireMeasurements(framework, ['dependencyCounts']) + await runFirstPartyDependencyScan(packageName) +} + +main().catch((error) => { + console.error('First-party dependency scan failed:', error) + process.exit(1) +}) diff --git a/packages/stats-generator/src/run-benchmarks-scripts/run-framework-dependency-scan.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-framework-dependency-scan.ts new file mode 100644 index 000000000..687a4e2aa --- /dev/null +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-framework-dependency-scan.ts @@ -0,0 +1,18 @@ +import { runFrameworkDependencyScan } from '../benchmarks/framework-dependencies/run-scan.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' + +async function main() { + const { packageName, framework } = await getBenchmarkContext({ + project: 'starter', + }) + requireMeasurements(framework, ['dependencyCounts']) + await runFrameworkDependencyScan(packageName, framework) +} + +main().catch((error) => { + console.error('Framework dependency scan failed:', error) + process.exit(1) +}) diff --git a/packages/stats-generator/src/run-benchmarks-scripts/run-install-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-install-benchmark.ts new file mode 100644 index 000000000..cb2c0554e --- /dev/null +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-install-benchmark.ts @@ -0,0 +1,18 @@ +import { runInstallBenchmark } from '../benchmarks/install/run-benchmark.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' + +async function main() { + const { packageName, framework } = await getBenchmarkContext({ + project: 'starter', + }) + requireMeasurements(framework, ['installDuration', 'dependencyCounts']) + await runInstallBenchmark(packageName, framework) +} + +main().catch((error) => { + console.error('Install benchmark failed:', error) + process.exit(1) +}) diff --git a/packages/stats-generator/src/run-benchmarks-scripts/run-node-engines-scan.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-node-engines-scan.ts new file mode 100644 index 000000000..531d808dc --- /dev/null +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-node-engines-scan.ts @@ -0,0 +1,18 @@ +import { runNodeEnginesScan } from '../benchmarks/node-engines/run-scan.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' + +async function main() { + const { packageName, framework } = await getBenchmarkContext({ + project: 'starter', + }) + requireMeasurements(framework, ['minimumNodeVersion']) + await runNodeEnginesScan(packageName, framework) +} + +main().catch((error) => { + console.error('Node engines scan failed:', error) + process.exit(1) +}) diff --git a/packages/stats-generator/src/run-server-side-rendered-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-server-side-rendered-benchmark.ts similarity index 82% rename from packages/stats-generator/src/run-server-side-rendered-benchmark.ts rename to packages/stats-generator/src/run-benchmarks-scripts/run-server-side-rendered-benchmark.ts index 25cf45a9a..3ce1d2d34 100644 --- a/packages/stats-generator/src/run-server-side-rendered-benchmark.ts +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-server-side-rendered-benchmark.ts @@ -1,11 +1,11 @@ -import { measurementsConfig } from './measurements.ts' -import { runServerSideRenderedBenchmark } from './serverSideRendered/index.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import { runServerSideRenderedBenchmark } from '../benchmarks/server-side-rendered/index.ts' +import { benchmarkOutputPath } from '../utils/paths.ts' import { - benchmarkOutputPath, getBenchmarkContext, requireMeasurements, - writeJsonFile, -} from './utils.ts' +} from '../utils/benchmark-context.ts' +import { writeJsonFile } from '../utils/files.ts' async function main() { const { packageName, framework, projectConfig, frameworkVersion } = diff --git a/packages/stats-generator/src/scripts/run-ssr-initial-load-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-initial-load-benchmark.ts similarity index 69% rename from packages/stats-generator/src/scripts/run-ssr-initial-load-benchmark.ts rename to packages/stats-generator/src/run-benchmarks-scripts/run-ssr-initial-load-benchmark.ts index 66264ebc7..2db101b56 100644 --- a/packages/stats-generator/src/scripts/run-ssr-initial-load-benchmark.ts +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-initial-load-benchmark.ts @@ -1,11 +1,11 @@ -import { runInitialLoadBenchmark } from '../initialLoad/run-initial-load-benchmark.ts' -import { measurementsConfig } from '../measurements.ts' +import { runInitialLoadBenchmark } from '../benchmarks/initial-load/run-initial-load-benchmark.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import { benchmarkOutputPath } from '../utils/paths.ts' import { - benchmarkOutputPath, getBenchmarkContext, requireMeasurements, - writeJsonFile, -} from '../utils.ts' +} from '../utils/benchmark-context.ts' +import { writeJsonFile } from '../utils/files.ts' async function main() { const { packageName, framework, projectConfig, frameworkVersion } = diff --git a/packages/stats-generator/src/scripts/run-ssr-initial-load-framework-images-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-initial-load-framework-images-benchmark.ts similarity index 76% rename from packages/stats-generator/src/scripts/run-ssr-initial-load-framework-images-benchmark.ts rename to packages/stats-generator/src/run-benchmarks-scripts/run-ssr-initial-load-framework-images-benchmark.ts index 71bf87ae7..8efefd370 100644 --- a/packages/stats-generator/src/scripts/run-ssr-initial-load-framework-images-benchmark.ts +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-initial-load-framework-images-benchmark.ts @@ -1,11 +1,11 @@ -import { runInitialLoadBenchmark } from '../initialLoad/run-initial-load-benchmark.ts' -import { measurementsConfig } from '../measurements.ts' +import { runInitialLoadBenchmark } from '../benchmarks/initial-load/run-initial-load-benchmark.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import { benchmarkOutputPath } from '../utils/paths.ts' import { - benchmarkOutputPath, getBenchmarkContext, requireMeasurements, - writeJsonFile, -} from '../utils.ts' +} from '../utils/benchmark-context.ts' +import { writeJsonFile } from '../utils/files.ts' async function main() { const { packageName, framework, projectConfig, frameworkVersion } = diff --git a/packages/stats-generator/src/scripts/run-ssr-initial-load-images-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-initial-load-images-benchmark.ts similarity index 75% rename from packages/stats-generator/src/scripts/run-ssr-initial-load-images-benchmark.ts rename to packages/stats-generator/src/run-benchmarks-scripts/run-ssr-initial-load-images-benchmark.ts index 17d28c630..b88a6caf3 100644 --- a/packages/stats-generator/src/scripts/run-ssr-initial-load-images-benchmark.ts +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-initial-load-images-benchmark.ts @@ -1,11 +1,11 @@ -import { runInitialLoadBenchmark } from '../initialLoad/run-initial-load-benchmark.ts' -import { measurementsConfig } from '../measurements.ts' +import { runInitialLoadBenchmark } from '../benchmarks/initial-load/run-initial-load-benchmark.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import { benchmarkOutputPath } from '../utils/paths.ts' import { - benchmarkOutputPath, getBenchmarkContext, requireMeasurements, - writeJsonFile, -} from '../utils.ts' +} from '../utils/benchmark-context.ts' +import { writeJsonFile } from '../utils/files.ts' async function main() { const { packageName, framework, projectConfig, frameworkVersion } = diff --git a/packages/stats-generator/src/run-ssr-load-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-load-benchmark.ts similarity index 81% rename from packages/stats-generator/src/run-ssr-load-benchmark.ts rename to packages/stats-generator/src/run-benchmarks-scripts/run-ssr-load-benchmark.ts index a8ab398b8..85902c05d 100644 --- a/packages/stats-generator/src/run-ssr-load-benchmark.ts +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-load-benchmark.ts @@ -1,13 +1,16 @@ import { SSRLoadStageOptions } from '@framework-performance/results/benchmark-types' import { getLoadPeakStage } from '@framework-performance/results/selection' -import { getSSRLoadKind, getSSRLoadPath } from './ssrLoad/config.ts' -import { runSSRLoadBenchmark } from './ssrLoad/index.ts' import { - benchmarkOutputPath, + getSSRLoadKind, + getSSRLoadPath, +} from '../benchmarks/ssr-load/config.ts' +import { runSSRLoadBenchmark } from '../benchmarks/ssr-load/index.ts' +import { benchmarkOutputPath } from '../utils/paths.ts' +import { getBenchmarkContext, requireMeasurements, - writeJsonFile, -} from './utils.ts' +} from '../utils/benchmark-context.ts' +import { writeJsonFile } from '../utils/files.ts' async function main() { const { packageName, framework, projectConfig, frameworkVersion } = diff --git a/packages/stats-generator/src/run-ssr-load-server.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-load-server.ts similarity index 72% rename from packages/stats-generator/src/run-ssr-load-server.ts rename to packages/stats-generator/src/run-benchmarks-scripts/run-ssr-load-server.ts index b0c3b0a0c..abbc2a05b 100644 --- a/packages/stats-generator/src/run-ssr-load-server.ts +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-load-server.ts @@ -1,7 +1,16 @@ -import { getSSRLoadKind, getSSRLoadPath } from './ssrLoad/config.ts' -import { DEFAULT_SSR_LOAD_PORT, startSSRLoadServer } from './ssrLoad/index.ts' -import { getHost, getPort } from './serve/common.ts' -import { getBenchmarkContext, requireMeasurements } from './utils.ts' +import { + getSSRLoadKind, + getSSRLoadPath, +} from '../benchmarks/ssr-load/config.ts' +import { + DEFAULT_SSR_LOAD_PORT, + startSSRLoadServer, +} from '../benchmarks/ssr-load/index.ts' +import { getHost, getPort } from '../app-servers/common.ts' +import { + getBenchmarkContext, + requireMeasurements, +} from '../utils/benchmark-context.ts' async function main() { const { packageName, framework, projectConfig } = await getBenchmarkContext({ diff --git a/packages/stats-generator/src/run-ssr-request-throughput-benchmark.ts b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-request-throughput-benchmark.ts similarity index 71% rename from packages/stats-generator/src/run-ssr-request-throughput-benchmark.ts rename to packages/stats-generator/src/run-benchmarks-scripts/run-ssr-request-throughput-benchmark.ts index f1f7ad156..4e90e895b 100644 --- a/packages/stats-generator/src/run-ssr-request-throughput-benchmark.ts +++ b/packages/stats-generator/src/run-benchmarks-scripts/run-ssr-request-throughput-benchmark.ts @@ -1,11 +1,11 @@ -import { measurementsConfig } from './measurements.ts' -import { runSSRRequestThroughputBenchmark } from './ssrRequestThroughput/index.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import { runSSRRequestThroughputBenchmark } from '../benchmarks/ssr-request-throughput/index.ts' +import { benchmarkOutputPath } from '../utils/paths.ts' import { - benchmarkOutputPath, getBenchmarkContext, requireMeasurements, - writeJsonFile, -} from './utils.ts' +} from '../utils/benchmark-context.ts' +import { writeJsonFile } from '../utils/files.ts' async function main() { const { packageName, framework, projectConfig, frameworkVersion } = diff --git a/packages/stats-generator/src/scripts/format-e18e-stats.ts b/packages/stats-generator/src/scripts/format-e18e-stats.ts index bc35c24b7..ae9869c7e 100644 --- a/packages/stats-generator/src/scripts/format-e18e-stats.ts +++ b/packages/stats-generator/src/scripts/format-e18e-stats.ts @@ -1,7 +1,7 @@ import { readFileSync } from 'node:fs' import { z } from 'zod' import { DependencyCountBenchmark } from '@framework-performance/results/benchmark-schemas' -import { writeJsonFile } from '../utils.ts' +import { writeJsonFile } from '../utils/files.ts' export const e18eStats = z .object({ diff --git a/packages/stats-generator/src/scripts/prepare-ci-results.ts b/packages/stats-generator/src/scripts/prepare-ci-results.ts index 964c08171..05b8a67d0 100644 --- a/packages/stats-generator/src/scripts/prepare-ci-results.ts +++ b/packages/stats-generator/src/scripts/prepare-ci-results.ts @@ -2,9 +2,9 @@ import { mkdirSync, writeFileSync } from 'node:fs' import { join } from 'node:path' import { BenchmarkCIResultSchema } from '@framework-performance/results/benchmark-schemas' import { readBenchmarkResult } from '@framework-performance/results/storage' -import { frameworksConfig } from '../frameworks.ts' -import { getPublishTimes } from '../release-dates.ts' -import { getPackageJsonDeps } from '../utils.ts' +import { frameworksConfig } from '@framework-performance/results/frameworks-config' +import { getPublishTimes } from '../utils/release-dates.ts' +import { getPackageJsonDeps } from '../utils/package-metadata.ts' const outputDirectory = process.argv[2] mkdirSync(outputDirectory, { recursive: true }) diff --git a/packages/stats-generator/src/scripts/print-frameworks.ts b/packages/stats-generator/src/scripts/print-frameworks.ts new file mode 100644 index 000000000..4177f96e1 --- /dev/null +++ b/packages/stats-generator/src/scripts/print-frameworks.ts @@ -0,0 +1,3 @@ +import { frameworksConfig } from '@framework-performance/results/frameworks-config' + +process.stdout.write(JSON.stringify(frameworksConfig)) diff --git a/packages/stats-generator/src/save-ci-stats.ts b/packages/stats-generator/src/scripts/save-ci-stats.ts similarity index 89% rename from packages/stats-generator/src/save-ci-stats.ts rename to packages/stats-generator/src/scripts/save-ci-stats.ts index 9e9d950af..15d3bf94d 100644 --- a/packages/stats-generator/src/save-ci-stats.ts +++ b/packages/stats-generator/src/scripts/save-ci-stats.ts @@ -7,13 +7,13 @@ import { type BenchmarkResult, } from '@framework-performance/results/benchmark-schemas' import { withSummaryVariance } from '@framework-performance/results/comparison' -import { measurementsConfig } from './measurements.ts' -import { getSSRLoadPath } from './ssrLoad/config.ts' +import { measurementsConfig } from '@framework-performance/results/measurements-config' +import { getSSRLoadPath } from '../benchmarks/ssr-load/config.ts' import { join } from 'node:path' -import { getFrameworks } from './get-frameworks.ts' +import { frameworksConfig } from '@framework-performance/results/frameworks-config' import { globSync } from 'node:fs' -import { readJsonFile } from './utils.ts' -import type { FrameworkConfig } from './types.ts' +import { readJsonFile } from '../utils/files.ts' +import type { FrameworkConfig } from '../types.ts' function readArtifact>(file: string) { const artifact = readJsonFile(file) @@ -31,7 +31,7 @@ export async function processCIStats( frameworks?: FrameworkConfig[] } = {}, ) { - const frameworks = configuredFrameworks ?? (await getFrameworks()) + const frameworks: FrameworkConfig[] = configuredFrameworks ?? frameworksConfig const results = new Map() for (const framework of frameworks) { diff --git a/packages/stats-generator/src/sync-versions.ts b/packages/stats-generator/src/scripts/sync-versions.ts similarity index 96% rename from packages/stats-generator/src/sync-versions.ts rename to packages/stats-generator/src/scripts/sync-versions.ts index 1848bada0..921dd0061 100644 --- a/packages/stats-generator/src/sync-versions.ts +++ b/packages/stats-generator/src/scripts/sync-versions.ts @@ -1,7 +1,7 @@ import { readFile } from 'node:fs/promises' import { join } from 'node:path' -import { getFrameworks } from './get-frameworks.ts' -import { packagesDir } from './constants.ts' +import { frameworksConfig } from '@framework-performance/results/frameworks-config' +import { packagesDir } from '../utils/paths.ts' interface VersionMismatch { frameworkPackage: string @@ -41,10 +41,9 @@ function extractVersion( } async function checkVersions(): Promise { - const frameworks = await getFrameworks() const mismatches: VersionMismatch[] = [] - const pairs = frameworks.filter((f) => f.starter && f.app) + const pairs = frameworksConfig.filter((f) => f.starter && f.app) console.info(`Checking ${pairs.length} framework package pair(s)...\n`) for (const framework of pairs) { diff --git a/packages/stats-generator/src/validate-first-party-dependencies.ts b/packages/stats-generator/src/scripts/validate-first-party-dependencies.ts similarity index 74% rename from packages/stats-generator/src/validate-first-party-dependencies.ts rename to packages/stats-generator/src/scripts/validate-first-party-dependencies.ts index 22ddeefce..da36e521d 100644 --- a/packages/stats-generator/src/validate-first-party-dependencies.ts +++ b/packages/stats-generator/src/scripts/validate-first-party-dependencies.ts @@ -1,14 +1,14 @@ import { join } from 'node:path' -import { packagesDir } from './constants.ts' -import { validateFirstPartyDependencyManifest } from './first-party-dependencies.ts' -import { getFrameworks } from './get-frameworks.ts' -import { getPackageJsonDeps, readJsonFile } from './utils.ts' +import { packagesDir } from '../utils/paths.ts' +import { validateFirstPartyDependencyManifest } from '../benchmarks/first-party-dependencies/first-party-dependencies.ts' +import { frameworksConfig } from '@framework-performance/results/frameworks-config' +import { getPackageJsonDeps } from '../utils/package-metadata.ts' +import { readJsonFile } from '../utils/files.ts' async function main() { - const frameworks = await getFrameworks() const failures: string[] = [] - for (const framework of frameworks) { + for (const framework of frameworksConfig) { if (!framework.starter) continue const packageName = framework.starter.package diff --git a/packages/stats-generator/src/types.ts b/packages/stats-generator/src/types.ts index 61e5b4e93..0a64297db 100644 --- a/packages/stats-generator/src/types.ts +++ b/packages/stats-generator/src/types.ts @@ -1,4 +1,4 @@ -import type { InteractionWork } from './interaction-work.ts' +import type { InteractionWork } from './benchmarks/shared/interaction-work.ts' export type { FrameworkConfig, TestConfig, diff --git a/packages/stats-generator/src/utils.ts b/packages/stats-generator/src/utils.ts deleted file mode 100644 index b384b35d9..000000000 --- a/packages/stats-generator/src/utils.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { execFileSync } from 'node:child_process' -import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs' -import { join, dirname } from 'node:path' -import { packagesDir } from './constants.ts' -import { getFrameworks } from './get-frameworks.ts' -import type { FrameworkProject } from '@framework-performance/results/benchmark-types' -import type { FrameworkConfig, PackageJson } from './types.ts' - -/** Get directory size in bytes using du on Linux and macOS. */ -export function getDirectorySize(dirPath: string): number { - try { - const output = execFileSync('du', ['-sk', dirPath], { encoding: 'utf-8' }) - const sizeKb = Number.parseInt(output.split(/\s+/)[0], 10) - return sizeKb * 1024 - } catch (error) { - console.warn(`Warning: Could not get directory size for ${dirPath}:`, error) - return 0 - } -} - -/** - * Read and parse a JSON file. Returns null if file doesn't exist or can't be parsed. - */ -export function readJsonFile(filePath: string): T | null { - try { - if (!existsSync(filePath)) { - return null - } - const content = readFileSync(filePath, 'utf-8') - return JSON.parse(content) as T - } catch (error) { - console.warn(`Warning: Failed to read ${filePath}:`, error) - return null - } -} - -export function benchmarkOutputPath(packageName: string, file: string) { - return join( - process.env.BENCHMARK_OUTPUT_DIR ?? packagesDir, - packageName, - file, - ) -} - -/** - * Write data to a JSON file, creating directories if needed. - */ -export function writeJsonFile(filePath: string, data: unknown): void { - const dir = dirname(filePath) - if (!existsSync(dir)) { - mkdirSync(dir, { recursive: true }) - } - writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`) -} - -export function getPackageJsonDeps(packageName: string) { - const packageJsonPath = join(packagesDir, packageName, 'package.json') - const packageJson = JSON.parse( - readFileSync(packageJsonPath, 'utf-8'), - ) as PackageJson - - return { - dependencies: packageJson.dependencies ?? {}, - devDependencies: packageJson.devDependencies ?? {}, - } -} - -function getFrameworkDependencyName(frameworkPackage: string): string { - return frameworkPackage.startsWith('jsr:') - ? frameworkPackage.slice('jsr:'.length) - : frameworkPackage -} - -export function getFrameworkDependencyCountsFromPackageMetadata( - starterPackageName: string, - frameworkPackage: string, -) { - // pnpm exposes JSR dependencies under their package name in node_modules. - const installedPackageName = getFrameworkDependencyName(frameworkPackage) - const packageJsonPath = join( - packagesDir, - starterPackageName, - 'node_modules', - installedPackageName, - 'package.json', - ) - const packageJson = JSON.parse( - readFileSync(packageJsonPath, 'utf-8'), - ) as PackageJson - const dependencies = packageJson.dependencies ?? {} - const devDependencies = packageJson.devDependencies ?? {} - - return { - productionDependencyCount: { - value: Object.keys(dependencies).length, - unit: 'count', - }, - developmentDependencyCount: { - value: Object.keys(devDependencies).length, - unit: 'count', - }, - } -} - -function getFrameworkVersion( - packageName: string, - frameworkPackage: string, -): string { - if (frameworkPackage === 'node') { - return process.version.replace(/^v/, '') - } - - const pkgJsonPath = join( - packagesDir, - packageName, - 'node_modules', - frameworkPackage, - 'package.json', - ) - const pkg = readJsonFile<{ version?: unknown }>(pkgJsonPath) - if (typeof pkg?.version !== 'string' || !pkg.version) - throw new Error( - `Missing framework version for ${frameworkPackage} in ${packageName}`, - ) - return pkg.version -} - -export function requireMeasurements( - framework: FrameworkConfig, - measurements: FrameworkConfig['measurements'], -) { - if ( - !measurements.some((measurement) => - framework.measurements.includes(measurement), - ) - ) { - throw new Error( - `${framework.name} requires at least one configured measurement from: ${measurements.join(', ')}`, - ) - } -} - -export async function getBenchmarkContext({ - project, -}: { - project: FrameworkProject -}) { - const frameworkName = process.argv[2] - if (!frameworkName) - throw new Error('Framework name is required (e.g. astro).') - - const framework = (await getFrameworks()).find( - ({ name }) => name === frameworkName, - ) - if (!framework) throw new Error(`Unknown framework: ${frameworkName}`) - const projectConfig = framework[project] - if (!projectConfig) - throw new Error(`No ${project} configured for ${frameworkName}`) - return { - packageName: projectConfig.package, - framework, - projectConfig, - get frameworkVersion() { - return getFrameworkVersion( - projectConfig.package, - framework.frameworkPackage, - ) - }, - } -} diff --git a/packages/stats-generator/src/utils/benchmark-context.ts b/packages/stats-generator/src/utils/benchmark-context.ts new file mode 100644 index 000000000..42935fee0 --- /dev/null +++ b/packages/stats-generator/src/utils/benchmark-context.ts @@ -0,0 +1,73 @@ +import { join } from 'node:path' +import { + frameworksConfig, + type FrameworkConfig, +} from '@framework-performance/results/frameworks-config' +import type { FrameworkProject } from '@framework-performance/results/benchmark-types' +import { packagesDir } from './paths.ts' +import { readJsonFile } from './files.ts' + +function getFrameworkVersion( + packageName: string, + frameworkPackage: string, +): string { + if (frameworkPackage === 'node') { + return process.version.replace(/^v/, '') + } + + const pkgJsonPath = join( + packagesDir, + packageName, + 'node_modules', + frameworkPackage, + 'package.json', + ) + const pkg = readJsonFile<{ version?: unknown }>(pkgJsonPath) + if (typeof pkg?.version !== 'string' || !pkg.version) + throw new Error( + `Missing framework version for ${frameworkPackage} in ${packageName}`, + ) + return pkg.version +} + +export function requireMeasurements( + framework: FrameworkConfig, + measurements: FrameworkConfig['measurements'], +) { + if ( + !measurements.some((measurement) => + framework.measurements.includes(measurement), + ) + ) { + throw new Error( + `${framework.name} requires at least one configured measurement from: ${measurements.join(', ')}`, + ) + } +} + +export async function getBenchmarkContext({ + project, +}: { + project: FrameworkProject +}) { + const frameworkName = process.argv[2] + if (!frameworkName) + throw new Error('Framework name is required (e.g. astro).') + + const framework = frameworksConfig.find(({ name }) => name === frameworkName) + if (!framework) throw new Error(`Unknown framework: ${frameworkName}`) + const projectConfig = framework[project] + if (!projectConfig) + throw new Error(`No ${project} configured for ${frameworkName}`) + return { + packageName: projectConfig.package, + framework, + projectConfig, + get frameworkVersion() { + return getFrameworkVersion( + projectConfig.package, + framework.frameworkPackage, + ) + }, + } +} diff --git a/packages/stats-generator/src/utils/files.ts b/packages/stats-generator/src/utils/files.ts new file mode 100644 index 000000000..4ae9ac21e --- /dev/null +++ b/packages/stats-generator/src/utils/files.ts @@ -0,0 +1,42 @@ +import { execFileSync } from 'node:child_process' +import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs' +import { dirname } from 'node:path' + +/** Get directory size in bytes using du on Linux and macOS. */ +export function getDirectorySize(dirPath: string): number { + try { + const output = execFileSync('du', ['-sk', dirPath], { encoding: 'utf-8' }) + const sizeKb = Number.parseInt(output.split(/\s+/)[0], 10) + return sizeKb * 1024 + } catch (error) { + console.warn(`Warning: Could not get directory size for ${dirPath}:`, error) + return 0 + } +} + +/** + * Read and parse a JSON file. Returns null if file doesn't exist or can't be parsed. + */ +export function readJsonFile(filePath: string): T | null { + try { + if (!existsSync(filePath)) { + return null + } + const content = readFileSync(filePath, 'utf-8') + return JSON.parse(content) as T + } catch (error) { + console.warn(`Warning: Failed to read ${filePath}:`, error) + return null + } +} + +/** + * Write data to a JSON file, creating directories if needed. + */ +export function writeJsonFile(filePath: string, data: unknown): void { + const dir = dirname(filePath) + if (!existsSync(dir)) { + mkdirSync(dir, { recursive: true }) + } + writeFileSync(filePath, `${JSON.stringify(data, null, 2)}\n`) +} diff --git a/packages/stats-generator/src/find-chromium.ts b/packages/stats-generator/src/utils/find-chromium.ts similarity index 100% rename from packages/stats-generator/src/find-chromium.ts rename to packages/stats-generator/src/utils/find-chromium.ts diff --git a/packages/stats-generator/src/utils/package-metadata.ts b/packages/stats-generator/src/utils/package-metadata.ts new file mode 100644 index 000000000..9be576006 --- /dev/null +++ b/packages/stats-generator/src/utils/package-metadata.ts @@ -0,0 +1,53 @@ +import { readFileSync } from 'node:fs' +import { join } from 'node:path' +import { packagesDir } from './paths.ts' +import type { PackageJson } from '../types.ts' + +export function getPackageJsonDeps(packageName: string) { + const packageJsonPath = join(packagesDir, packageName, 'package.json') + const packageJson = JSON.parse( + readFileSync(packageJsonPath, 'utf-8'), + ) as PackageJson + + return { + dependencies: packageJson.dependencies ?? {}, + devDependencies: packageJson.devDependencies ?? {}, + } +} + +function getFrameworkDependencyName(frameworkPackage: string): string { + return frameworkPackage.startsWith('jsr:') + ? frameworkPackage.slice('jsr:'.length) + : frameworkPackage +} + +export function getFrameworkDependencyCountsFromPackageMetadata( + starterPackageName: string, + frameworkPackage: string, +) { + // pnpm exposes JSR dependencies under their package name in node_modules. + const installedPackageName = getFrameworkDependencyName(frameworkPackage) + const packageJsonPath = join( + packagesDir, + starterPackageName, + 'node_modules', + installedPackageName, + 'package.json', + ) + const packageJson = JSON.parse( + readFileSync(packageJsonPath, 'utf-8'), + ) as PackageJson + const dependencies = packageJson.dependencies ?? {} + const devDependencies = packageJson.devDependencies ?? {} + + return { + productionDependencyCount: { + value: Object.keys(dependencies).length, + unit: 'count', + }, + developmentDependencyCount: { + value: Object.keys(devDependencies).length, + unit: 'count', + }, + } +} diff --git a/packages/stats-generator/src/utils/paths.ts b/packages/stats-generator/src/utils/paths.ts new file mode 100644 index 000000000..1b6ea9da3 --- /dev/null +++ b/packages/stats-generator/src/utils/paths.ts @@ -0,0 +1,15 @@ +import { dirname, join } from 'node:path' +import { fileURLToPath } from 'node:url' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) + +export const packagesDir = join(__dirname, '../../..') + +export function benchmarkOutputPath(packageName: string, file: string) { + return join( + process.env.BENCHMARK_OUTPUT_DIR ?? packagesDir, + packageName, + file, + ) +} diff --git a/packages/stats-generator/src/benchmark-utils.ts b/packages/stats-generator/src/utils/project.ts similarity index 96% rename from packages/stats-generator/src/benchmark-utils.ts rename to packages/stats-generator/src/utils/project.ts index 693b14146..92f0deee5 100644 --- a/packages/stats-generator/src/benchmark-utils.ts +++ b/packages/stats-generator/src/utils/project.ts @@ -1,7 +1,7 @@ import { execFileSync } from 'node:child_process' import { cpSync, mkdirSync } from 'node:fs' import { dirname, join, relative } from 'node:path' -import { packagesDir } from './constants.ts' +import { packagesDir } from './paths.ts' export function installDependencies( cwd: string, diff --git a/packages/stats-generator/src/release-dates.ts b/packages/stats-generator/src/utils/release-dates.ts similarity index 100% rename from packages/stats-generator/src/release-dates.ts rename to packages/stats-generator/src/utils/release-dates.ts