2026-03-10 00:00:00 -07:00
|
|
|
import { spawnSync } from 'node:child_process'
|
|
|
|
|
import { resolve } from 'node:path'
|
|
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
|
|
|
|
|
|
import { getBenchOptions, measure, printResults } from './_shared.mjs'
|
|
|
|
|
|
|
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
|
|
|
const repoRoot = resolve(__dirname, '..', '..')
|
|
|
|
|
|
|
|
|
|
const options = getBenchOptions()
|
|
|
|
|
|
|
|
|
|
const scenarios = [
|
|
|
|
|
{ name: 'cli.help', args: ['--help'] },
|
|
|
|
|
{ name: 'cli.version', args: ['--version'] },
|
|
|
|
|
{ name: 'cli.doctor', args: ['doctor', '--cwd', 'src/cli/__fixtures__/tiny-fastify', '--quiet'] },
|
|
|
|
|
{ name: 'cli.observe.check', args: ['observe', '--cwd', 'src/cli/__fixtures__/observe-config', '--profile', 'staging-observe', '--check-config', '--quiet'] },
|
2026-03-10 00:00:00 -07:00
|
|
|
{ name: 'cli.qualify', args: ['qualify', '--cwd', 'src/cli/__fixtures__/protocol-lab', '--profile', 'oauth-nightly', '--seed', '42', '--quiet'] },
|
2026-03-10 00:00:00 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
async function run() {
|
|
|
|
|
const results = []
|
|
|
|
|
|
|
|
|
|
for (const scenario of scenarios) {
|
|
|
|
|
const row = await measure(
|
|
|
|
|
scenario.name,
|
|
|
|
|
async () => {
|
|
|
|
|
const proc = spawnSync(
|
|
|
|
|
process.execPath,
|
|
|
|
|
['dist/cli/index.js', ...scenario.args],
|
|
|
|
|
{
|
|
|
|
|
cwd: repoRoot,
|
|
|
|
|
stdio: 'pipe',
|
|
|
|
|
encoding: 'utf8',
|
|
|
|
|
env: { ...process.env, FORCE_COLOR: '0' },
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if (proc.status !== 0) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`Scenario ${scenario.name} failed with code ${proc.status}\nstdout:\n${proc.stdout}\nstderr:\n${proc.stderr}`
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
options,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
results.push(row)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printResults('CLI Benchmarks', results, options)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run().catch((error) => {
|
|
|
|
|
console.error(error)
|
|
|
|
|
process.exit(1)
|
|
|
|
|
})
|