Skip to content

Commit ab7d6d0

Browse files
authored
Merge pull request #16 from camillobruni/2024-11-26_ms
Store times and scores explicitly
2 parents 707b7a8 + 513b6bc commit ab7d6d0

File tree

1 file changed

+72
-54
lines changed

1 file changed

+72
-54
lines changed

JetStreamDriver.js

Lines changed: 72 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function displayCategoryScores() {
6565

6666
let summaryElement = document.getElementById("result-summary");
6767
for (let [category, scores] of categoryScores)
68-
summaryElement.innerHTML += `<p> ${category}: ${uiFriendlyNumber(geomean(scores))}</p>`
68+
summaryElement.innerHTML += `<p> ${category}: ${uiFriendlyScore(geomean(scores))}</p>`
6969

7070
categoryScores = null;
7171
}
@@ -159,6 +159,10 @@ function uiFriendlyNumber(num) {
159159
return num.toFixed(3);
160160
}
161161

162+
function uiFriendlyScore(num) {
163+
return uiFriendlyNumber(num);
164+
}
165+
162166
function uiFriendlyDuration(time)
163167
{
164168
const minutes = time.getMinutes();
@@ -286,30 +290,30 @@ class Driver {
286290

287291
categoryScores = new Map;
288292
for (const benchmark of this.benchmarks) {
289-
for (let category of Object.keys(benchmark.subTimes()))
293+
for (let category of Object.keys(benchmark.subScores()))
290294
categoryScores.set(category, []);
291295
}
292296

293297
for (const benchmark of this.benchmarks) {
294-
for (let [category, value] of Object.entries(benchmark.subTimes())) {
298+
for (let [category, value] of Object.entries(benchmark.subScores())) {
295299
const arr = categoryScores.get(category);
296300
arr.push(value);
297301
}
298302
}
299303

300304
if (isInBrowser) {
301305
summaryElement.classList.add('done');
302-
summaryElement.innerHTML = "<div class=\"score\">" + uiFriendlyNumber(geomean(allScores)) + "</div><label>Score</label>";
306+
summaryElement.innerHTML = "<div class=\"score\">" + uiFriendlyScore(geomean(allScores)) + "</div><label>Score</label>";
303307
summaryElement.onclick = displayCategoryScores;
304308
if (showScoreDetails)
305309
displayCategoryScores();
306310
statusElement.innerHTML = '';
307311
} else if (!dumpJSONResults) {
308312
console.log("\n");
309313
for (let [category, scores] of categoryScores)
310-
console.log(`${category}: ${uiFriendlyNumber(geomean(scores))}`);
314+
console.log(`${category}: ${uiFriendlyScore(geomean(scores))}`);
311315

312-
console.log("\nTotal Score: ", uiFriendlyNumber(geomean(allScores)), "\n");
316+
console.log("\nTotal Score: ", uiFriendlyScore(geomean(allScores)), "\n");
313317
}
314318

315319
this.reportScoreToRunBenchmarkRunner();
@@ -484,9 +488,9 @@ class Driver {
484488
const results = {};
485489
for (const benchmark of this.benchmarks) {
486490
const subResults = {}
487-
const subTimes = benchmark.subTimes();
488-
for (const name in subTimes) {
489-
subResults[name] = {"metrics": {"Time": {"current": [toTimeValue(subTimes[name])]}}};
491+
const subScores = benchmark.subScores();
492+
for (const name in subScores) {
493+
subResults[name] = {"metrics": {"Time": {"current": [toTimeValue(subScores[name])]}}};
490494
}
491495
results[benchmark.name] = {
492496
"metrics" : {
@@ -915,9 +919,12 @@ class DefaultBenchmark extends Benchmark {
915919
super(...args);
916920

917921
this.worstCaseCount = getWorstCaseCount(this.plan);
918-
this.firstIteration = null;
919-
this.worst4 = null;
920-
this.average = null;
922+
this.firstIterationTime = null;
923+
this.firstIterationScore = null;
924+
this.worst4Time = null;
925+
this.worst4Score = null;
926+
this.averageTime = null;
927+
this.averageScore = null;
921928

922929
assert(this.iterations > this.worstCaseCount);
923930
}
@@ -931,7 +938,8 @@ class DefaultBenchmark extends Benchmark {
931938
}
932939
results = copyArray(results);
933940

934-
this.firstIteration = toScore(results[0]);
941+
this.firstIterationTime = results[0];
942+
this.firstIterationScore = toScore(results[0]);
935943

936944
results = results.slice(1);
937945
results.sort((a, b) => a < b ? 1 : -1);
@@ -941,19 +949,21 @@ class DefaultBenchmark extends Benchmark {
941949
const worstCase = [];
942950
for (let i = 0; i < this.worstCaseCount; ++i)
943951
worstCase.push(results[i]);
944-
this.worst4 = toScore(mean(worstCase));
945-
this.average = toScore(mean(results));
952+
this.worst4Time = mean(worstCase);
953+
this.worst4Score = toScore(this.worst4Time);
954+
this.averageTime = mean(results);
955+
this.averageScore = toScore(this.averageTime);
946956
}
947957

948958
get score() {
949-
return geomean([this.firstIteration, this.worst4, this.average]);
959+
return geomean([this.firstIterationScore, this.worst4Score, this.averageScore]);
950960
}
951961

952-
subTimes() {
962+
subScores() {
953963
return {
954-
"First": this.firstIteration,
955-
"Worst": this.worst4,
956-
"Average": this.average,
964+
"First": this.firstIterationScore,
965+
"Worst": this.worst4Score,
966+
"Average": this.averageScore,
957967
};
958968
}
959969

@@ -969,20 +979,20 @@ class DefaultBenchmark extends Benchmark {
969979
super.updateUIAfterRun();
970980

971981
if (isInBrowser) {
972-
document.getElementById(firstID(this)).innerHTML = uiFriendlyNumber(this.firstIteration);
973-
document.getElementById(worst4ID(this)).innerHTML = uiFriendlyNumber(this.worst4);
974-
document.getElementById(avgID(this)).innerHTML = uiFriendlyNumber(this.average);
975-
document.getElementById(scoreID(this)).innerHTML = uiFriendlyNumber(this.score);
982+
document.getElementById(firstID(this)).innerHTML = uiFriendlyScore(this.firstIterationScore);
983+
document.getElementById(worst4ID(this)).innerHTML = uiFriendlyScore(this.worst4Score);
984+
document.getElementById(avgID(this)).innerHTML = uiFriendlyScore(this.averageScore);
985+
document.getElementById(scoreID(this)).innerHTML = uiFriendlyScore(this.score);
976986
return;
977987
}
978988

979989
if (dumpJSONResults)
980990
return;
981991

982-
console.log(" Startup:", uiFriendlyNumber(this.firstIteration));
983-
console.log(" Worst Case:", uiFriendlyNumber(this.worst4));
984-
console.log(" Average:", uiFriendlyNumber(this.average));
985-
console.log(" Score:", uiFriendlyNumber(this.score));
992+
console.log(" Startup:", uiFriendlyScore(this.firstIterationScore));
993+
console.log(" Worst Case:", uiFriendlyScore(this.worst4Score));
994+
console.log(" Average:", uiFriendlyScore(this.averageScore));
995+
console.log(" Score:", uiFriendlyScore(this.score));
986996
if (RAMification) {
987997
console.log(" Current Footprint:", uiFriendlyNumber(this.currentFootprint));
988998
console.log(" Peak Footprint:", uiFriendlyNumber(this.peakFootprint));
@@ -1106,17 +1116,21 @@ class WSLBenchmark extends Benchmark {
11061116
constructor(...args) {
11071117
super(...args);
11081118

1109-
this.stdlib = null;
1110-
this.mainRun = null;
1119+
this.stdlibTime = null;
1120+
this.stdlibScore = null;
1121+
this.mainRunTime = null;
1122+
this.mainRunScore = null;
11111123
}
11121124

11131125
processResults(results) {
1114-
this.stdlib = toScore(results[0]);
1115-
this.mainRun = toScore(results[1]);
1126+
this.stdlibTime = results[0];
1127+
this.stdlibScore = toScore(results[0]);
1128+
this.mainRunTime = results[1];
1129+
this.mainRunScore = toScore(results[1]);
11161130
}
11171131

11181132
get score() {
1119-
return geomean([this.stdlib, this.mainRun]);
1133+
return geomean([this.stdlibScore, this.mainRunScore]);
11201134
}
11211135

11221136
get runnerCode() {
@@ -1139,10 +1153,10 @@ class WSLBenchmark extends Benchmark {
11391153
`;
11401154
}
11411155

1142-
subTimes() {
1156+
subScores() {
11431157
return {
1144-
"Stdlib": this.stdlib,
1145-
"MainRun": this.mainRun,
1158+
"Stdlib": this.stdlibScore,
1159+
"MainRun": this.mainRunScore,
11461160
};
11471161
}
11481162

@@ -1158,18 +1172,18 @@ class WSLBenchmark extends Benchmark {
11581172
super.updateUIAfterRun();
11591173

11601174
if (isInBrowser) {
1161-
document.getElementById("wsl-stdlib-score").innerHTML = uiFriendlyNumber(this.stdlib);
1162-
document.getElementById("wsl-tests-score").innerHTML = uiFriendlyNumber(this.mainRun);
1163-
document.getElementById("wsl-score-score").innerHTML = uiFriendlyNumber(this.score);
1175+
document.getElementById("wsl-stdlib-score").innerHTML = uiFriendlyScore(this.stdlibScore);
1176+
document.getElementById("wsl-tests-score").innerHTML = uiFriendlyScore(this.mainRunScore);
1177+
document.getElementById("wsl-score-score").innerHTML = uiFriendlyScore(this.score);
11641178
return;
11651179
}
11661180

11671181
if (dumpJSONResults)
11681182
return;
11691183

1170-
console.log(" Stdlib:", uiFriendlyNumber(this.stdlib));
1171-
console.log(" Tests:", uiFriendlyNumber(this.mainRun));
1172-
console.log(" Score:", uiFriendlyNumber(this.score));
1184+
console.log(" Stdlib:", uiFriendlyScore(this.stdlibScore));
1185+
console.log(" Tests:", uiFriendlyScore(this.mainRunScore));
1186+
console.log(" Score:", uiFriendlyScore(this.score));
11731187
if (RAMification) {
11741188
console.log(" Current Footprint:", uiFriendlyNumber(this.currentFootprint));
11751189
console.log(" Peak Footprint:", uiFriendlyNumber(this.peakFootprint));
@@ -1183,16 +1197,20 @@ class WasmLegacyBenchmark extends Benchmark {
11831197
super(...args);
11841198

11851199
this.startupTime = null;
1200+
this.startupScore = null;
11861201
this.runTime = null;
1202+
this.runScore = null;
11871203
}
11881204

11891205
processResults(results) {
1190-
this.startupTime = toScore(results[0]);
1191-
this.runTime = toScore(results[1]);
1206+
this.startupTime = results[0];
1207+
this.startupScore= toScore(results[0]);
1208+
this.runTime = results[1];
1209+
this.runScore = toScore(results[1]);
11921210
}
11931211

11941212
get score() {
1195-
return geomean([this.startupTime, this.runTime]);
1213+
return geomean([this.startupScore, this.runScore]);
11961214
}
11971215

11981216
get prerunCode() {
@@ -1311,10 +1329,10 @@ class WasmLegacyBenchmark extends Benchmark {
13111329
return str;
13121330
}
13131331

1314-
subTimes() {
1332+
subScores() {
13151333
return {
1316-
"Startup": this.startupTime,
1317-
"Runtime": this.runTime,
1334+
"Startup": this.startupScore,
1335+
"Runtime": this.runScore,
13181336
};
13191337
}
13201338

@@ -1340,18 +1358,18 @@ class WasmLegacyBenchmark extends Benchmark {
13401358
super.updateUIAfterRun();
13411359

13421360
if (isInBrowser) {
1343-
document.getElementById(this.startupID).innerHTML = uiFriendlyNumber(this.startupTime);
1344-
document.getElementById(this.runID).innerHTML = uiFriendlyNumber(this.runTime);
1345-
document.getElementById(this.scoreID).innerHTML = uiFriendlyNumber(this.score);
1361+
document.getElementById(this.startupID).innerHTML = uiFriendlyScore(this.startupScore);
1362+
document.getElementById(this.runID).innerHTML = uiFriendlyScore(this.runScore);
1363+
document.getElementById(this.scoreID).innerHTML = uiFriendlyScore(this.score);
13461364
return;
13471365
}
13481366

13491367
if (dumpJSONResults)
13501368
return;
13511369

1352-
console.log(" Startup:", uiFriendlyNumber(this.startupTime));
1353-
console.log(" Run time:", uiFriendlyNumber(this.runTime));
1354-
console.log(" Score:", uiFriendlyNumber(this.score));
1370+
console.log(" Startup:", uiFriendlyScore(this.startupScore));
1371+
console.log(" Run time:", uiFriendlyScore(this.runScore));
1372+
console.log(" Score:", uiFriendlyScore(this.score));
13551373
if (RAMification) {
13561374
console.log(" Current Footprint:", uiFriendlyNumber(this.currentFootprint));
13571375
console.log(" Peak Footprint:", uiFriendlyNumber(this.peakFootprint));

0 commit comments

Comments
 (0)