Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/instructions/benchmark.instructions.md
Original file line number Diff line number Diff line change
@@ -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 "<path>" 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).
24 changes: 12 additions & 12 deletions test/benchmark/Event.benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -14,12 +14,12 @@ perfContext('Emitter.fire()', () => {
before(() => {
emitter = new Emitter<number>();
});
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', () => {
Expand All @@ -29,12 +29,12 @@ perfContext('Emitter.fire()', () => {
emitter = new Emitter<number>();
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', () => {
Expand All @@ -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', () => {
Expand All @@ -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();
});
});
Loading