Skip to content

Commit c432b1a

Browse files
authored
Add group-details parameter to conditionally display grouped benchmarks (#157)
Displaying all sub group details is very convenient for local debugging.
1 parent bc144e1 commit c432b1a

File tree

4 files changed

+66
-31
lines changed

4 files changed

+66
-31
lines changed

JetStreamDriver.js

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -281,35 +281,10 @@ class Driver {
281281
}
282282
}
283283

284-
prepareToRun() {
285-
this.benchmarks.sort((a, b) => a.plan.name.toLowerCase() < b.plan.name.toLowerCase() ? 1 : -1);
286-
284+
prepareBrowserUI() {
287285
let text = "";
288-
for (const benchmark of this.benchmarks) {
289-
const description = Object.keys(benchmark.subScores());
290-
description.push("Score");
291-
292-
const scoreIds = benchmark.scoreIdentifiers();
293-
const overallScoreId = scoreIds.pop();
294-
295-
if (isInBrowser) {
296-
text +=
297-
`<div class="benchmark" id="benchmark-${benchmark.name}">
298-
<h3 class="benchmark-name">${benchmark.name} <a class="info" href="in-depth.html#${benchmark.name}">i</a></h3>
299-
<h4 class="score" id="${overallScoreId}">&nbsp;</h4>
300-
<h4 class="plot" id="plot-${benchmark.name}">&nbsp;</h4>
301-
<p>`;
302-
for (let i = 0; i < scoreIds.length; i++) {
303-
const scoreId = scoreIds[i];
304-
const label = description[i];
305-
text += `<span class="result"><span id="${scoreId}">&nbsp;</span><label>${label}</label></span>`
306-
}
307-
text += `</p></div>`;
308-
}
309-
}
310-
311-
if (!isInBrowser)
312-
return;
286+
for (const benchmark of this.benchmarks)
287+
text += benchmark.renderHTML();
313288

314289
const timestamp = performance.now();
315290
document.getElementById('jetstreams').style.backgroundImage = `url('jetstreams.svg?${timestamp}')`;
@@ -349,7 +324,9 @@ class Driver {
349324
if (isInBrowser)
350325
window.addEventListener("error", (e) => this.pushError("driver startup", e.error));
351326
await this.prefetchResources();
352-
this.prepareToRun();
327+
this.benchmarks.sort((a, b) => a.plan.name.toLowerCase() < b.plan.name.toLowerCase() ? 1 : -1);
328+
if (isInBrowser)
329+
this.prepareBrowserUI();
353330
this.isReady = true;
354331
if (isInBrowser) {
355332
globalThis.dispatchEvent(new Event("JetStreamReady"));
@@ -763,6 +740,26 @@ class Benchmark {
763740
return code;
764741
}
765742

743+
renderHTML() {
744+
const description = Object.keys(this.subScores());
745+
description.push("Score");
746+
747+
const scoreIds = this.scoreIdentifiers();
748+
const overallScoreId = scoreIds.pop();
749+
let text = `<div class="benchmark" id="benchmark-${this.name}">
750+
<h3 class="benchmark-name">${this.name} <a class="info" href="in-depth.html#${this.name}">i</a></h3>
751+
<h4 class="score" id="${overallScoreId}">&nbsp;</h4>
752+
<h4 class="plot" id="plot-${this.name}">&nbsp;</h4>
753+
<p>`;
754+
for (let i = 0; i < scoreIds.length; i++) {
755+
const scoreId = scoreIds[i];
756+
const label = description[i];
757+
text += `<span class="result"><span id="${scoreId}">&nbsp;</span><label>${label}</label></span>`
758+
}
759+
text += `</p></div>`;
760+
return text;
761+
}
762+
766763
async run() {
767764
if (this.isDone)
768765
throw new Error(`Cannot run Benchmark ${this.name} twice`);
@@ -1012,11 +1009,15 @@ class Benchmark {
10121009

10131010
updateUIBeforeRun() {
10141011
if (!JetStreamParams.dumpJSONResults)
1015-
console.log(`Running ${this.name}:`);
1012+
this.updateConsoleBeforeRun();
10161013
if (isInBrowser)
10171014
this.updateUIBeforeRunInBrowser();
10181015
}
10191016

1017+
updateConsoleBeforeRun() {
1018+
console.log(`Running ${this.name}:`);
1019+
}
1020+
10201021
updateUIBeforeRunInBrowser() {
10211022
const resultsBenchmarkUI = document.getElementById(`benchmark-${this.name}`);
10221023
resultsBenchmarkUI.classList.add("benchmark-running");
@@ -1112,6 +1113,26 @@ class GroupedBenchmark extends Benchmark {
11121113
for (const benchmark of this.benchmarks)
11131114
benchmark.prefetchResourcesForShell();
11141115
}
1116+
1117+
renderHTML() {
1118+
let text = super.renderHTML();
1119+
if (JetStreamParams.groupDetails) {
1120+
for (const benchmark of this.benchmarks)
1121+
text += benchmark.renderHTML();
1122+
}
1123+
return text;
1124+
}
1125+
1126+
updateConsoleBeforeRun() {
1127+
if (!JetStreamParams.groupDetails)
1128+
super.updateConsoleBeforeRun();
1129+
}
1130+
1131+
updateConsoleAfterRun(scoreEntries) {
1132+
if (JetStreamParams.groupDetails)
1133+
super.updateConsoleBeforeRun();
1134+
super.updateConsoleAfterRun(scoreEntries);
1135+
}
11151136

11161137
get files() {
11171138
let files = [];
@@ -1128,8 +1149,13 @@ class GroupedBenchmark extends Benchmark {
11281149
let benchmark;
11291150
try {
11301151
this._state = BenchmarkState.RUNNING;
1131-
for (benchmark of this.benchmarks)
1152+
for (benchmark of this.benchmarks) {
1153+
if (JetStreamParams.groupDetails)
1154+
benchmark.updateUIBeforeRun();
11321155
await benchmark.run();
1156+
if (JetStreamParams.groupDetails)
1157+
benchmark.updateUIAfterRun();
1158+
}
11331159
} catch (e) {
11341160
this._state = BenchmarkState.ERROR;
11351161
console.log(`Error in runCode of grouped benchmark ${benchmark.name}: `, e);

cli.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const CLI_PARAMS = {
5252
help: "Do not prefetch resources. Will add network overhead to measurements!",
5353
param: "prefetchResources",
5454
},
55+
"group-details": {
56+
help: "Display detailed group items",
57+
param: "groupDetails",
58+
},
5559
test: {
5660
help: "Run a specific test or comma-separated list of tests.",
5761
param: "test",

params.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class Params {
3838
testWorstCaseCount = undefined;
3939
prefetchResources = true;
4040

41+
// Display group details.
42+
groupDetails = false
43+
4144
RAMification = false;
4245
dumpJSONResults = false;
4346
dumpTestList = false;
@@ -61,6 +64,7 @@ class Params {
6164
this.prefetchResources = this._parseBooleanParam(sourceParams, "prefetchResources");
6265
this.RAMification = this._parseBooleanParam(sourceParams, "RAMification");
6366
this.dumpJSONResults = this._parseBooleanParam(sourceParams, "dumpJSONResults");
67+
this.groupDetails = this._parseBooleanParam(sourceParams, "groupDetails");
6468
this.dumpTestList = this._parseBooleanParam(sourceParams, "dumpTestList");
6569

6670
this.customPreIterationCode = this._parseStringParam(sourceParams, "customPreIterationCode");

tests/run-shell.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async function runTests() {
110110
success &&= await runTest("Run UnitTests", () => sh(shellBinary, UNIT_TEST_PATH));
111111
success &&= await runCLITest("Run Single Suite", shellBinary, "proxy-mobx");
112112
success &&= await runCLITest("Run Tag No Prefetch", shellBinary, "proxy", "--no-prefetch");
113+
success &&= await runCLITest("Run Grouped with Details", shellBinary, "SunSpider", "--group-details");
113114
success &&= await runCLITest("Run Disabled Suite", shellBinary, "disabled");
114115
success &&= await runCLITest("Run Default Suite", shellBinary);
115116
if (!success)

0 commit comments

Comments
 (0)