summaryrefslogtreecommitdiff
path: root/benchmark/bench/server-stress.js
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--benchmark/bench/server-stress.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/benchmark/bench/server-stress.js b/benchmark/bench/server-stress.js
index 9e93c4cd9..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;
@@ -28,9 +28,11 @@ export async function run(projectDir, outputFile) {
});
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...');
@@ -59,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(
{
@@ -76,7 +78,7 @@ async function benchmarkCannon() {
instance.stop();
resolve(result);
}
- }
+ },
);
autocannon.track(instance, { renderResultsTable: false });
});
@@ -95,7 +97,7 @@ function printResult(output) {
],
{
align: ['l', 'r', 'r', 'r'],
- }
+ },
);
const reqAndBytesTable = markdownTable(
@@ -106,7 +108,7 @@ function printResult(output) {
],
{
align: ['l', 'r', 'r', 'r', 'r'],
- }
+ },
);
return `${latencyTable}\n\n${reqAndBytesTable}`;