Skip to content

Commit 4719e3f

Browse files
authored
Use TEST_INVOKER_LOOKUP (#439)
Add generic lookup dict for the test-invoker class. This makes future extensions and local hacking easier.
1 parent 3ce6105 commit 4719e3f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

resources/benchmark-runner.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ class RAFTestInvoker extends TestInvoker {
315315
}
316316
}
317317

318+
const TEST_INVOKER_LOOKUP = {
319+
__proto__: null,
320+
timer: TimerTestInvoker,
321+
raf: RAFTestInvoker,
322+
};
323+
318324
// https://stackoverflow.com/a/47593316
319325
function seededHashRandomNumberGenerator(a) {
320326
return function () {
@@ -642,7 +648,7 @@ export class SuiteRunner {
642648
performance.measure(`${suite.name}.${test.name}-async`, asyncStartLabel, asyncEndLabel);
643649
};
644650
const report = () => this._recordTestResults(suite, test, syncTime, asyncTime);
645-
const invokerClass = params.measurementMethod === "raf" ? RAFTestInvoker : TimerTestInvoker;
651+
const invokerClass = TEST_INVOKER_LOOKUP[params.measurementMethod];
646652
const invoker = new invokerClass(runSync, measureAsync, report);
647653

648654
return invoker.start();

0 commit comments

Comments
 (0)