diff --git a/.github/instructions/benchmark.instructions.md b/.github/instructions/benchmark.instructions.md new file mode 100644 index 00000000..2e586708 --- /dev/null +++ b/.github/instructions/benchmark.instructions.md @@ -0,0 +1,18 @@ +--- +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` + +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). 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(); }); });