diff options
Diffstat (limited to 'benchmark/bench/server-stress.js')
-rw-r--r-- | benchmark/bench/server-stress.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/benchmark/bench/server-stress.js b/benchmark/bench/server-stress.js index 18b31c71c..5bcaa6963 100644 --- a/benchmark/bench/server-stress.js +++ b/benchmark/bench/server-stress.js @@ -1,10 +1,10 @@ -import autocannon from 'autocannon'; -import { exec } from 'tinyexec'; -import { markdownTable } from 'markdown-table'; import fs from 'node:fs/promises'; import { fileURLToPath } from 'node:url'; +import autocannon from 'autocannon'; +import { markdownTable } from 'markdown-table'; import { waitUntilBusy } from 'port-authority'; import pb from 'pretty-bytes'; +import { exec } from 'tinyexec'; import { astroBin } from './_util.js'; const port = 4321; @@ -24,12 +24,15 @@ export async function run(projectDir, outputFile) { cwd: root, stdio: 'inherit', }, + throwOnError: true, }); console.log('Previewing...'); - const previewProcess = execaCommand(`${astroBin} preview --port ${port}`, { - cwd: root, - stdio: 'inherit', + const previewProcess = await exec(astroBin, ['preview', '--port', port], { + nodeOptions: { + cwd: root, + stdio: 'inherit', + }, }); console.log('Waiting for server ready...'); @@ -58,7 +61,7 @@ export async function run(projectDir, outputFile) { /** * @returns {Promise<import('autocannon').Result>} */ -async function benchmarkCannon() { +export async function benchmarkCannon() { return new Promise((resolve, reject) => { const instance = autocannon( { @@ -75,7 +78,7 @@ async function benchmarkCannon() { instance.stop(); resolve(result); } - } + }, ); autocannon.track(instance, { renderResultsTable: false }); }); @@ -94,7 +97,7 @@ function printResult(output) { ], { align: ['l', 'r', 'r', 'r'], - } + }, ); const reqAndBytesTable = markdownTable( @@ -105,7 +108,7 @@ function printResult(output) { ], { align: ['l', 'r', 'r', 'r', 'r'], - } + }, ); return `${latencyTable}\n\n${reqAndBytesTable}`; |