Skip to content

Commit

Permalink
Use TEST_INVOKER_LOOKUP (WebKit#439)
Browse files Browse the repository at this point in the history
Add generic lookup dict for the test-invoker class.
This makes future extensions and local hacking easier.
  • Loading branch information
camillobruni authored Oct 23, 2024
1 parent 3ce6105 commit 4719e3f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion resources/benchmark-runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ class RAFTestInvoker extends TestInvoker {
}
}

const TEST_INVOKER_LOOKUP = {
__proto__: null,
timer: TimerTestInvoker,
raf: RAFTestInvoker,
};

// https://stackoverflow.com/a/47593316
function seededHashRandomNumberGenerator(a) {
return function () {
Expand Down Expand Up @@ -642,7 +648,7 @@ export class SuiteRunner {
performance.measure(`${suite.name}.${test.name}-async`, asyncStartLabel, asyncEndLabel);
};
const report = () => this._recordTestResults(suite, test, syncTime, asyncTime);
const invokerClass = params.measurementMethod === "raf" ? RAFTestInvoker : TimerTestInvoker;
const invokerClass = TEST_INVOKER_LOOKUP[params.measurementMethod];
const invoker = new invokerClass(runSync, measureAsync, report);

return invoker.start();
Expand Down

0 comments on commit 4719e3f

Please sign in to comment.