Skip to content

Commit

Permalink
Remove interactive runner (WebKit#432)
Browse files Browse the repository at this point in the history
- To simplify future runner refactorings we remove the interactive runner.
- Stepping functionality is added to the developer-menu and integrated directly into the default MainBenchmarkClient.
  • Loading branch information
camillobruni authored Oct 11, 2024
1 parent c2e8d4f commit 2a4d041
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 262 deletions.
40 changes: 0 additions & 40 deletions InteractiveRunner.html

This file was deleted.

16 changes: 11 additions & 5 deletions resources/developer-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,20 @@ function createUIForSuites() {
}

function createUIForRun() {
let button = document.createElement("button");
button.textContent = "Start Test";
button.onclick = (event) => {
const stepTestButton = document.createElement("button");
stepTestButton.textContent = "Step Test \u23EF";
stepTestButton.onclick = (event) => {
globalThis.benchmarkClient.step();
};
const startTestButton = document.createElement("button");
startTestButton.textContent = "Start Test \u23F5";
startTestButton.onclick = (event) => {
globalThis.benchmarkClient.start();
};
let buttons = document.createElement("div");
const buttons = document.createElement("div");
buttons.className = "button-bar";
buttons.appendChild(button);
buttons.appendChild(stepTestButton);
buttons.appendChild(startTestButton);
return buttons;
}

Expand Down
213 changes: 0 additions & 213 deletions resources/interactive.mjs

This file was deleted.

43 changes: 39 additions & 4 deletions resources/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,50 @@ class MainBenchmarkClient {
_hasResults = false;
_developerModeContainer = null;
_metrics = Object.create(null);
_steppingPromise = null;
_steppingResolver = null;

constructor() {
window.addEventListener("DOMContentLoaded", () => this.prepareUI());
this._showSection(window.location.hash);
}

start() {
if (this._startBenchmark())
if (this._isStepping())
this._clearStepping();
else if (this._startBenchmark())
this._showSection("#running");
}

step() {
const currentSteppingResolver = this._steppingResolver;
this._steppingPromise = new Promise((resolve) => {
this._steppingResolver = resolve;
});
if (this._isStepping())
currentSteppingResolver();
if (!this._isRunning) {
this._startBenchmark();
this._showSection("#running");
}
}

_clearStepping() {
const currentSteppingResolver = this._steppingResolver;
this._steppingPromise = null;
this._steppingResolver = null;
currentSteppingResolver();
}

async _awaitNextStep(suite, test) {
console.log(`Next Step: ${suite.name} ${test.name}`, { suite, test });
await this._steppingPromise;
}

_isStepping() {
return this._steppingResolver !== null;
}

_startBenchmark() {
if (this._isRunning)
return false;
Expand All @@ -44,8 +77,8 @@ class MainBenchmarkClient {

return false;
}

this._developerModeContainer?.remove();
if (!this._isStepping())
this._developerModeContainer?.remove();
this._progressCompleted = document.getElementById("progress-completed");
if (params.iterationCount < 50) {
const progressNode = document.getElementById("progress");
Expand Down Expand Up @@ -81,9 +114,11 @@ class MainBenchmarkClient {
frame.style.transform = "translate(-50%, -50%)";
}

willRunTest(suite, test) {
async willRunTest(suite, test) {
document.getElementById("info-label").textContent = suite.name;
document.getElementById("info-progress").textContent = `${this._finishedTestCount} / ${this.stepCount}`;
if (this._steppingPromise)
await this._awaitNextStep(suite, test);
}

didRunTest() {
Expand Down

0 comments on commit 2a4d041

Please sign in to comment.