From 8dbac09682bc9db0c64ef287aaddfc57ab0d95c4 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Sat, 30 May 2026 05:14:29 -0500 Subject: [PATCH] ref(bench): return promise --- bench/fixtures/utils.ts | 14 ++++++++------ bench/startup.bench.ts | 8 ++------ 2 files changed, 10 insertions(+), 12 deletions(-) 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()); -- 2.51.2