diff --git a/bench/fixtures/utils.ts b/bench/fixtures/utils.ts index 6b9c2e5..68bf77d 100644 --- a/bench/fixtures/utils.ts +++ b/bench/fixtures/utils.ts @@ -1,12 +1,14 @@ import { fileURLToPath } from "node:url"; -import { spawnSync } from "node:child_process"; +import { spawn } from "node:child_process"; export const fixture = (name: string) => { return new URL(`./${name}/mod.ts`, import.meta.url); }; -export const spawnFixture = (name: string) => - spawnSync(process.execPath, [ - ...process.execArgv, - fileURLToPath(fixture(name)), - ], { stdio: "ignore" }); +export const spawnFixture = (name: string): Promise => + new Promise((resolve) => { + spawn(process.execPath, [ + ...process.execArgv, + fileURLToPath(fixture(name)), + ], { stdio: "ignore" }).on("close", resolve); + }); diff --git a/bench/startup.bench.ts b/bench/startup.bench.ts index 1535ce0..5a559d0 100644 --- a/bench/startup.bench.ts +++ b/bench/startup.bench.ts @@ -5,12 +5,8 @@ import { spawnFixture } from "./fixtures/utils.ts"; let bench = withCodSpeed(new Bench({ name: "startup" })); bench - .add("createTerm", async () => { - spawnFixture("create-term"); - }) - .add("time to first render", async () => { - spawnFixture("render-minimal"); - }); + .add("createTerm", () => spawnFixture("create-term")) + .add("time to first render", () => spawnFixture("render-minimal")); await bench.run(); console.table(bench.table());