From 431d511c95bea32c7eb164e628cb0e3fee77d1a4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:28:11 -0800 Subject: [PATCH 1/2] Fix benchmark usage, add instructions --- .../instructions/benchmark.instructions.md | 16 +++++++++++++ ...tructions.md => unit-test.instructions.md} | 0 test/benchmark/Event.benchmark.ts | 24 +++++++++---------- 3 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 .github/instructions/benchmark.instructions.md rename .github/instructions/{unit-test-instructions.instructions.md => unit-test.instructions.md} (100%) diff --git a/.github/instructions/benchmark.instructions.md b/.github/instructions/benchmark.instructions.md new file mode 100644 index 00000000..94f5c7a7 --- /dev/null +++ b/.github/instructions/benchmark.instructions.md @@ -0,0 +1,16 @@ +--- +applyTo: '**/*.benchmark.ts' +--- +# Benchmark run instructions + +- Full suite: `npm run benchmark` +- Single benchmark file: + - Tree: `npm run benchmark -- -t out-test/benchmark/Event.benchmark.js` + - Run file: `npm run benchmark -- -s "out-test/benchmark/Event.benchmark.js" out-test/benchmark/Event.benchmark.js` +- Single context/case: + - Use `-t` to get the path, then: + - `npm run benchmark -- -s "" out-test/benchmark/Event.benchmark.js` + +Notes: +- Benchmarks run from built JS in `out-test/benchmark/*.benchmark.js`. +- Keep `NODE_PATH=./out` (handled by the npm script). diff --git a/.github/instructions/unit-test-instructions.instructions.md b/.github/instructions/unit-test.instructions.md similarity index 100% rename from .github/instructions/unit-test-instructions.instructions.md rename to .github/instructions/unit-test.instructions.md diff --git a/test/benchmark/Event.benchmark.ts b/test/benchmark/Event.benchmark.ts index 76f23f91..9cd8216d 100644 --- a/test/benchmark/Event.benchmark.ts +++ b/test/benchmark/Event.benchmark.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { perfContext, before, ThroughputRuntimeCase } from 'xterm-benchmark'; +import { perfContext, before, RuntimeCase } from 'xterm-benchmark'; import { Emitter } from 'common/Event'; const ITERATIONS = 1_000_000; @@ -14,12 +14,12 @@ perfContext('Emitter.fire()', () => { before(() => { emitter = new Emitter(); }); - new ThroughputRuntimeCase('', () => { + new RuntimeCase('', () => { for (let i = 0; i < ITERATIONS; i++) { emitter.fire(i); } return { payloadSize: ITERATIONS }; - }, { fork: false }).showAverageThroughput(); + }, { fork: false }).showAverageRuntime(); }); perfContext('1 listener', () => { @@ -29,12 +29,12 @@ perfContext('Emitter.fire()', () => { emitter = new Emitter(); emitter.event(e => { sum += e; }); }); - new ThroughputRuntimeCase('', () => { + new RuntimeCase('', () => { for (let i = 0; i < ITERATIONS; i++) { emitter.fire(i); } - return { payloadSize: ITERATIONS }; - }, { fork: false }).showAverageThroughput(); + return { payloadSize: ITERATIONS, sum }; + }, { fork: false }).showAverageRuntime(); }); perfContext('2 listeners', () => { @@ -45,12 +45,12 @@ perfContext('Emitter.fire()', () => { emitter.event(e => { sum += e; }); emitter.event(e => { sum += e * 2; }); }); - new ThroughputRuntimeCase('', () => { + new RuntimeCase('', () => { for (let i = 0; i < ITERATIONS; i++) { emitter.fire(i); } - return { payloadSize: ITERATIONS }; - }, { fork: false }).showAverageThroughput(); + return { payloadSize: ITERATIONS, sum }; + }, { fork: false }).showAverageRuntime(); }); perfContext('5 listeners', () => { @@ -62,11 +62,11 @@ perfContext('Emitter.fire()', () => { emitter.event(e => { sum += e; }); } }); - new ThroughputRuntimeCase('', () => { + new RuntimeCase('', () => { for (let i = 0; i < ITERATIONS; i++) { emitter.fire(i); } - return { payloadSize: ITERATIONS }; - }, { fork: false }).showAverageThroughput(); + return { payloadSize: ITERATIONS, sum }; + }, { fork: false }).showAverageRuntime(); }); }); From eed84230302b9ce01a138f517e3240038d9c6d0a Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:30:16 -0800 Subject: [PATCH 2/2] Clarify runtime cases --- .github/instructions/benchmark.instructions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/instructions/benchmark.instructions.md b/.github/instructions/benchmark.instructions.md index 94f5c7a7..2e586708 100644 --- a/.github/instructions/benchmark.instructions.md +++ b/.github/instructions/benchmark.instructions.md @@ -11,6 +11,8 @@ applyTo: '**/*.benchmark.ts' - Use `-t` to get the path, then: - `npm run benchmark -- -s "" out-test/benchmark/Event.benchmark.js` +When writing instructions, use `RuntimeCase` to measure pure runtime in ms, use `ThroughputRuntimeCase` when measuring throughput in MB/s. + Notes: - Benchmarks run from built JS in `out-test/benchmark/*.benchmark.js`. - Keep `NODE_PATH=./out` (handled by the npm script).