Files
StellaOps Bot e6119cbe91
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
up
2025-11-24 09:07:40 +02:00

31 lines
1.1 KiB
TypeScript

import { chromium } from 'playwright';
import fs from 'fs';
const BASE_URL = process.env.GRAPH_UI_BASE ?? 'http://localhost:4200';
const OUT = process.env.OUT ?? 'out/graph-ui-perf';
const BUDGET_MS = Number(process.env.GRAPH_UI_BUDGET_MS ?? '3000');
(async () => {
fs.mkdirSync(OUT, { recursive: true });
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
const start = Date.now();
await page.goto(`${BASE_URL}/graph`, { waitUntil: 'networkidle' });
await page.click('text=Explore'); // assumes nav element
await page.waitForSelector('canvas');
const duration = Date.now() - start;
const metrics = await page.evaluate(() => JSON.stringify(window.performance.timing));
fs.writeFileSync(`${OUT}/timing.json`, metrics);
fs.writeFileSync(`${OUT}/duration.txt`, `${duration}`);
if (duration > BUDGET_MS) {
console.error(`[graph-ui] perf budget exceeded: ${duration}ms > ${BUDGET_MS}ms`);
process.exit(1);
}
await browser.close();
console.log(`[graph-ui] load duration ${duration}ms (budget ${BUDGET_MS}ms)`);
})();