From 4f9b76a480a33e11050b2cc6aa058232c9191392 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Mon, 1 Jun 2026 13:33:58 -0500 Subject: [PATCH 1/2] chore(bench): add input + combined startup benchmarks --- bench/fixtures/create-both/mod.ts | 7 +++++++ bench/fixtures/create-input/mod.ts | 3 +++ bench/fixtures/render-and-input/mod.ts | 17 +++++++++++++++++ bench/startup.bench.ts | 5 ++++- 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 bench/fixtures/create-both/mod.ts create mode 100644 bench/fixtures/create-input/mod.ts create mode 100644 bench/fixtures/render-and-input/mod.ts diff --git a/bench/fixtures/create-both/mod.ts b/bench/fixtures/create-both/mod.ts new file mode 100644 index 0000000..2b7e764 --- /dev/null +++ b/bench/fixtures/create-both/mod.ts @@ -0,0 +1,7 @@ +import { createTerm } from "../../../term.ts"; +import { createInput } from "../../../input.ts"; + +await Promise.all([ + createTerm({ width: 80, height: 24 }), + createInput(), +]); diff --git a/bench/fixtures/create-input/mod.ts b/bench/fixtures/create-input/mod.ts new file mode 100644 index 0000000..768b686 --- /dev/null +++ b/bench/fixtures/create-input/mod.ts @@ -0,0 +1,3 @@ +import { createInput } from "../../../input.ts"; + +await createInput(); diff --git a/bench/fixtures/render-and-input/mod.ts b/bench/fixtures/render-and-input/mod.ts new file mode 100644 index 0000000..8f2786e --- /dev/null +++ b/bench/fixtures/render-and-input/mod.ts @@ -0,0 +1,17 @@ +import { createTerm } from "../../../term.ts"; +import { close, grow, open, text } from "../../../ops.ts"; +import { createInput } from "../../../input.ts"; + +let [term, input] = await Promise.all([ + createTerm({ width: 80, height: 24 }), + createInput(), +]); + +term.render([ + open("root", { layout: { width: grow(), height: grow(), direction: "ttb" } }), + text("Hello, World!"), + close(), +]); + +// Up arrow (CSI A) — exercises the input parser path. +input.scan(new Uint8Array([0x1b, 0x5b, 0x41])); diff --git a/bench/startup.bench.ts b/bench/startup.bench.ts index 5a559d0..63a9a8a 100644 --- a/bench/startup.bench.ts +++ b/bench/startup.bench.ts @@ -6,7 +6,10 @@ let bench = withCodSpeed(new Bench({ name: "startup" })); bench .add("createTerm", () => spawnFixture("create-term")) - .add("time to first render", () => spawnFixture("render-minimal")); + .add("createInput", () => spawnFixture("create-input")) + .add("createTerm + createInput", () => spawnFixture("create-both")) + .add("time to first render", () => spawnFixture("render-minimal")) + .add("render + scan (both modules)", () => spawnFixture("render-and-input")); await bench.run(); console.table(bench.table()); From 2fbe48823d2d2276bf288a14e1fa2606a210a487 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Mon, 1 Jun 2026 16:32:26 -0500 Subject: [PATCH 2/2] ref(ci): run benches on codspeed-macro to avoid hardware variance --- .github/workflows/benchmark.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index cca1753..a8e348c 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -5,8 +5,7 @@ on: branches: [main] pull_request: branches: [main] - # `workflow_dispatch` allows CodSpeed to trigger backtest - # performance analysis in order to generate initial data. + # `workflow_dispatch` allows CodSpeed to trigger workflow_dispatch: permissions: {} @@ -67,7 +66,7 @@ jobs: simulation: name: Run benchmarks (simulation) needs: build - runs-on: ubuntu-latest + runs-on: codspeed-macro permissions: contents: read # clone repo id-token: write # upload benchmark results to codspeed