diff options
Diffstat (limited to 'benchmark/index.js')
-rwxr-xr-x | benchmark/index.js | 44 |
1 files changed, 9 insertions, 35 deletions
diff --git a/benchmark/index.js b/benchmark/index.js index 2f2846e1d..127fc4f5b 100755 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -1,7 +1,8 @@ import mri from 'mri'; import fs from 'node:fs/promises'; import path from 'node:path'; -import {fileURLToPath, pathToFileURL} from 'node:url'; +import { fileURLToPath, pathToFileURL } from 'node:url'; +import { makeProject } from './bench/_util.js'; const args = mri(process.argv.slice(2)); @@ -14,7 +15,6 @@ Command memory Run build memory and speed test render Run rendering speed test server-stress Run server stress test - codspeed Run codspeed test cli-startup Run CLI startup speed test Options @@ -30,7 +30,6 @@ const benchmarks = { render: () => import('./bench/render.js'), 'server-stress': () => import('./bench/server-stress.js'), 'cli-startup': () => import('./bench/cli-startup.js'), - codspeed: () => import('./bench/codspeed.js') }; if (commandName && !(commandName in benchmarks)) { @@ -39,26 +38,12 @@ if (commandName && !(commandName in benchmarks)) { } if (commandName) { - if (commandName === 'codspeed') { - const render = await makeProject('render-bench'); - const rootRender = fileURLToPath(render); - const bench = benchmarks[commandName]; - const benchMod = await bench(); - const payload = { - render: { - root: rootRender, - output: await getOutputFile('render') - }, - }; - await benchMod.run(payload); - } else { - // Run single benchmark - const bench = benchmarks[commandName]; - const benchMod = await bench(); - const projectDir = await makeProject(args.project || benchMod.defaultProject); - const outputFile = await getOutputFile(commandName); - await benchMod.run(projectDir, outputFile); - } + // Run single benchmark + const bench = benchmarks[commandName]; + const benchMod = await bench(); + const projectDir = await makeProject(args.project || benchMod.defaultProject); + const outputFile = await getOutputFile(commandName); + await benchMod.run(projectDir, outputFile); } else { // Run all benchmarks for (const name in benchmarks) { @@ -70,21 +55,10 @@ if (commandName) { } } -export async function makeProject(name) { - console.log('Making project:', name); - const projectDir = new URL(`./projects/${name}/`, import.meta.url); - - const makeProjectMod = await import(`./make-project/${name}.js`); - await makeProjectMod.run(projectDir); - - console.log('Finished making project:', name); - return projectDir; -} - /** * @param {string} benchmarkName */ -async function getOutputFile(benchmarkName) { +export async function getOutputFile(benchmarkName) { let file; if (args.output) { file = pathToFileURL(path.resolve(args.output)); |