MCPcopy Create free account
hub / github.com/BuilderIO/framework-benchmarks / measure

Function measure

src/scripts/measure.ts:47–80  ·  view source on GitHub ↗
(framework: string)

Source from the content-addressed store, hash-verified

45console.table(getTable(results));
46
47async function measure(framework: string) {
48 const { process: runningProcess, port } = await preview(framework);
49 // Give the server a sec to start up
50 await sleep(2000);
51
52 const measureUrl = `http://localhost:${port}${path}`;
53 console.info(
54 `Getting lighthouse report for ${chalk.green(framework)} on ${measureUrl}`
55 );
56
57 const { report } = await getLighthouseReport(measureUrl, RUNS);
58 results[framework] = getSimpleReport(report);
59
60 const outputDir = 'apps/components/src/reports';
61 const pathFragment = path === '/' ? '/' : path + '/';
62 const jsonPath = `${outputDir}${pathFragment}${framework}.json`;
63 const jsPath = `${outputDir}${pathFragment}${framework}.ts`;
64
65 if (process.env.NO_WRITE !== 'true') {
66 await Promise.all([
67 // Output results to a JSON file
68 fs.outputFile(jsonPath, JSON.stringify(report, null, 2)),
69 // Output results to a TS file for importing
70 fs.outputFile(
71 jsPath,
72 `export default ${JSON.stringify(report, null, 2)} as LH.Result`
73 ),
74 ]);
75 }
76
77 // Don't throw an error when we kill the process below
78 runningProcess.catch(() => null);
79 await runningProcess.kill();
80}

Callers 1

measure.tsFile · 0.70

Calls 3

previewFunction · 0.85
getLighthouseReportFunction · 0.85
getSimpleReportFunction · 0.85

Tested by

no test coverage detected