Skip to content

Commit e4c74c4

Browse files
committed
use scores *and* times
1 parent a463dd1 commit e4c74c4

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
@@ -59,7 +59,7 @@ function displayCategoryScores() {
5959

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

6464
categoryScores = null;
6565
}
@@ -153,6 +153,10 @@ function uiFriendlyNumber(num) {
153153
return num.toFixed(3);
154154
}
155155

156+
function uiFriendlyScore(num) {
157+
return uiFriendlyNumber(num);
158+
}
159+
156160
function uiFriendlyDuration(time)
157161
{
158162
const minutes = time.getMinutes();
@@ -280,30 +284,30 @@ class Driver {
280284

281285
categoryScores = new Map;
282286
for (const benchmark of this.benchmarks) {
283-
for (let category of Object.keys(benchmark.subTimes()))
287+
for (let category of Object.keys(benchmark.subScores()))
284288
categoryScores.set(category, []);
285289
}
286290

287291
for (const benchmark of this.benchmarks) {
288-
for (let [category, value] of Object.entries(benchmark.subTimes())) {
292+
for (let [category, value] of Object.entries(benchmark.subScores())) {
289293
const arr = categoryScores.get(category);
290294
arr.push(value);
291295
}
292296
}
293297

294298
if (isInBrowser) {
295299
summaryElement.classList.add('done');
296-
summaryElement.innerHTML = "<div class=\"score\">" + uiFriendlyNumber(geomean(allScores)) + "</div><label>Score</label>";
300+
summaryElement.innerHTML = "<div class=\"score\">" + uiFriendlyScore(geomean(allScores)) + "</div><label>Score</label>";
297301
summaryElement.onclick = displayCategoryScores;
298302
if (showScoreDetails)
299303
displayCategoryScores();
300304
statusElement.innerHTML = '';
301305
} else if (!dumpJSONResults) {
302306
console.log("\n");
303307
for (let [category, scores] of categoryScores)
304-
console.log(`${category}: ${uiFriendlyNumber(geomean(scores))}`);
308+
console.log(`${category}: ${uiFriendlyScore(geomean(scores))}`);
305309

306-
console.log("\nTotal Score: ", uiFriendlyNumber(geomean(allScores)), "\n");
310+
console.log("\nTotal Score: ", uiFriendlyScore(geomean(allScores)), "\n");
307311
}
308312

309313
this.reportScoreToRunBenchmarkRunner();
@@ -472,9 +476,9 @@ class Driver {
472476
const results = {};
473477
for (const benchmark of this.benchmarks) {
474478
const subResults = {}
475-
const subTimes = benchmark.subTimes();
476-
for (const name in subTimes) {
477-
subResults[name] = {"metrics": {"Time": {"current": [toTimeValue(subTimes[name])]}}};
479+
const subScores = benchmark.subScores();
480+
for (const name in subScores) {
481+
subResults[name] = {"metrics": {"Time": {"current": [toTimeValue(subScores[name])]}}};
478482
}
479483
results[benchmark.name] = {
480484
"metrics" : {
@@ -889,9 +893,12 @@ class DefaultBenchmark extends Benchmark {
889893
super(...args);
890894

891895
this.worstCaseCount = getWorstCaseCount(this.plan);
892-
this.firstIteration = null;
893-
this.worst4 = null;
894-
this.average = null;
896+
this.firstIterationTime = null;
897+
this.firstIterationScore = null;
898+
this.worst4Time = null;
899+
this.worst4Score = null;
900+
this.averageTime = null;
901+
this.averageScore = null;
895902

896903
assert(this.iterations > this.worstCaseCount);
897904
}
@@ -905,7 +912,8 @@ class DefaultBenchmark extends Benchmark {
905912
}
906913
results = copyArray(results);
907914

908-
this.firstIteration = toScore(results[0]);
915+
this.firstIterationTime = results[0];
916+
this.firstIterationScore = toScore(results[0]);
909917

910918
results = results.slice(1);
911919
results.sort((a, b) => a < b ? 1 : -1);
@@ -915,19 +923,21 @@ class DefaultBenchmark extends Benchmark {
915923
const worstCase = [];
916924
for (let i = 0; i < this.worstCaseCount; ++i)
917925
worstCase.push(results[i]);
918-
this.worst4 = toScore(mean(worstCase));
919-
this.average = toScore(mean(results));
926+
this.worst4Time = mean(worstCase);
927+
this.worst4Score = toScore(this.worst4Time);
928+
this.averageTime = mean(results);
929+
this.averageScore = toScore(this.averageTime);
920930
}
921931

922932
get score() {
923-
return geomean([this.firstIteration, this.worst4, this.average]);
933+
return geomean([this.firstIterationScore, this.worst4Score, this.averageScore]);
924934
}
925935

926-
subTimes() {
936+
subScores() {
927937
return {
928-
"First": this.firstIteration,
929-
"Worst": this.worst4,
930-
"Average": this.average,
938+
"First": this.firstIterationScore,
939+
"Worst": this.worst4Score,
940+
"Average": this.averageScore,
931941
};
932942
}
933943

@@ -943,20 +953,20 @@ class DefaultBenchmark extends Benchmark {
943953
super.updateUIAfterRun();
944954

945955
if (isInBrowser) {
946-
document.getElementById(firstID(this)).innerHTML = uiFriendlyNumber(this.firstIteration);
947-
document.getElementById(worst4ID(this)).innerHTML = uiFriendlyNumber(this.worst4);
948-
document.getElementById(avgID(this)).innerHTML = uiFriendlyNumber(this.average);
949-
document.getElementById(scoreID(this)).innerHTML = uiFriendlyNumber(this.score);
956+
document.getElementById(firstID(this)).innerHTML = uiFriendlyScore(this.firstIterationScore);
957+
document.getElementById(worst4ID(this)).innerHTML = uiFriendlyScore(this.worst4Score);
958+
document.getElementById(avgID(this)).innerHTML = uiFriendlyScore(this.averageScore);
959+
document.getElementById(scoreID(this)).innerHTML = uiFriendlyScore(this.score);
950960
return;
951961
}
952962

953963
if (dumpJSONResults)
954964
return;
955965

956-
console.log(" Startup:", uiFriendlyNumber(this.firstIteration));
957-
console.log(" Worst Case:", uiFriendlyNumber(this.worst4));
958-
console.log(" Average:", uiFriendlyNumber(this.average));
959-
console.log(" Score:", uiFriendlyNumber(this.score));
966+
console.log(" Startup:", uiFriendlyScore(this.firstIterationScore));
967+
console.log(" Worst Case:", uiFriendlyScore(this.worst4Score));
968+
console.log(" Average:", uiFriendlyScore(this.averageScore));
969+
console.log(" Score:", uiFriendlyScore(this.score));
960970
if (RAMification) {
961971
console.log(" Current Footprint:", uiFriendlyNumber(this.currentFootprint));
962972
console.log(" Peak Footprint:", uiFriendlyNumber(this.peakFootprint));
@@ -990,17 +1000,21 @@ class WSLBenchmark extends Benchmark {
9901000
constructor(...args) {
9911001
super(...args);
9921002

993-
this.stdlib = null;
994-
this.mainRun = null;
1003+
this.stdlibTime = null;
1004+
this.stdlibScore = null;
1005+
this.mainRunTime = null;
1006+
this.mainRunScore = null;
9951007
}
9961008

9971009
processResults(results) {
998-
this.stdlib = toScore(results[0]);
999-
this.mainRun = toScore(results[1]);
1010+
this.stdlibTime = results[0];
1011+
this.stdlibScore = toScore(results[0]);
1012+
this.mainRunTime = results[1];
1013+
this.mainRunScore = toScore(results[1]);
10001014
}
10011015

10021016
get score() {
1003-
return geomean([this.stdlib, this.mainRun]);
1017+
return geomean([this.stdlibScore, this.mainRunScore]);
10041018
}
10051019

10061020
get runnerCode() {
@@ -1023,10 +1037,10 @@ class WSLBenchmark extends Benchmark {
10231037
`;
10241038
}
10251039

1026-
subTimes() {
1040+
subScores() {
10271041
return {
1028-
"Stdlib": this.stdlib,
1029-
"MainRun": this.mainRun,
1042+
"Stdlib": this.stdlibScore,
1043+
"MainRun": this.mainRunScore,
10301044
};
10311045
}
10321046

@@ -1042,18 +1056,18 @@ class WSLBenchmark extends Benchmark {
10421056
super.updateUIAfterRun();
10431057

10441058
if (isInBrowser) {
1045-
document.getElementById("wsl-stdlib-score").innerHTML = uiFriendlyNumber(this.stdlib);
1046-
document.getElementById("wsl-tests-score").innerHTML = uiFriendlyNumber(this.mainRun);
1047-
document.getElementById("wsl-score-score").innerHTML = uiFriendlyNumber(this.score);
1059+
document.getElementById("wsl-stdlib-score").innerHTML = uiFriendlyScore(this.stdlibScore);
1060+
document.getElementById("wsl-tests-score").innerHTML = uiFriendlyScore(this.mainRunScore);
1061+
document.getElementById("wsl-score-score").innerHTML = uiFriendlyScore(this.score);
10481062
return;
10491063
}
10501064

10511065
if (dumpJSONResults)
10521066
return;
10531067

1054-
console.log(" Stdlib:", uiFriendlyNumber(this.stdlib));
1055-
console.log(" Tests:", uiFriendlyNumber(this.mainRun));
1056-
console.log(" Score:", uiFriendlyNumber(this.score));
1068+
console.log(" Stdlib:", uiFriendlyScore(this.stdlibScore));
1069+
console.log(" Tests:", uiFriendlyScore(this.mainRunScore));
1070+
console.log(" Score:", uiFriendlyScore(this.score));
10571071
if (RAMification) {
10581072
console.log(" Current Footprint:", uiFriendlyNumber(this.currentFootprint));
10591073
console.log(" Peak Footprint:", uiFriendlyNumber(this.peakFootprint));
@@ -1067,16 +1081,20 @@ class WasmBenchmark extends Benchmark {
10671081
super(...args);
10681082

10691083
this.startupTime = null;
1084+
this.startupScore = null;
10701085
this.runTime = null;
1086+
this.runScore = null;
10711087
}
10721088

10731089
processResults(results) {
1074-
this.startupTime = toScore(results[0]);
1075-
this.runTime = toScore(results[1]);
1090+
this.startupTime = results[0];
1091+
this.startupScore= toScore(results[0]);
1092+
this.runTime = results[1];
1093+
this.runScore = toScore(results[1]);
10761094
}
10771095

10781096
get score() {
1079-
return geomean([this.startupTime, this.runTime]);
1097+
return geomean([this.startupScore, this.runScore]);
10801098
}
10811099

10821100
get prerunCode() {
@@ -1194,10 +1212,10 @@ class WasmBenchmark extends Benchmark {
11941212
return str;
11951213
}
11961214

1197-
subTimes() {
1215+
subScores() {
11981216
return {
1199-
"Startup": this.startupTime,
1200-
"Runtime": this.runTime,
1217+
"Startup": this.startupScore,
1218+
"Runtime": this.runScore,
12011219
};
12021220
}
12031221

@@ -1223,22 +1241,22 @@ class WasmBenchmark extends Benchmark {
12231241
super.updateUIAfterRun();
12241242

12251243
if (isInBrowser) {
1226-
document.getElementById(this.startupID).innerHTML = uiFriendlyNumber(this.startupTime);
1227-
document.getElementById(this.runID).innerHTML = uiFriendlyNumber(this.runTime);
1228-
document.getElementById(this.scoreID).innerHTML = uiFriendlyNumber(this.score);
1244+
document.getElementById(this.startupID).innerHTML = uiFriendlyScore(this.startupScore);
1245+
document.getElementById(this.runID).innerHTML = uiFriendlyScore(this.runScore);
1246+
document.getElementById(this.scoreID).innerHTML = uiFriendlyScore(this.score);
12291247
return;
12301248
}
12311249

12321250
if (dumpJSONResults)
12331251
return;
12341252

1235-
console.log(" Startup:", uiFriendlyNumber(this.startupTime));
1236-
console.log(" Run time:", uiFriendlyNumber(this.runTime));
1253+
console.log(" Startup:", uiFriendlyScore(this.startupScore));
1254+
console.log(" Run time:", uiFriendlyScore(this.runScore));
12371255
if (RAMification) {
12381256
console.log(" Current Footprint:", uiFriendlyNumber(this.currentFootprint));
12391257
console.log(" Peak Footprint:", uiFriendlyNumber(this.peakFootprint));
12401258
}
1241-
console.log(" Score:", uiFriendlyNumber(this.score));
1259+
console.log(" Score:", uiFriendlyScore(this.score));
12421260
}
12431261
};
12441262

0 commit comments

Comments
 (0)