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 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());