Skip to content

Commit 80f97b2

Browse files
committed
Add button and shortcut to download results JSON
1 parent f2a1996 commit 80f97b2

4 files changed

Lines changed: 55 additions & 10 deletions

File tree

MotionMark/developer.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ <h1>MotionMark score</h1>
158158
<button onclick="benchmarkController.restartBenchmark()">Test Again</button>
159159
<p>
160160
'j': Show JSON results<br/>
161+
'd': Download JSON results<br/>
161162
's': Select various results for copy/paste (use repeatedly to cycle)
162163
</p>
163164
</div>

MotionMark/resources/debug-runner/motionmark.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,6 @@ body.showing-test-container.tiles-classic {
517517
}
518518

519519
#overlay button {
520-
margin: 2em auto;
521520
border-color: rgb(241, 241, 241);
522521
color: rgb(241, 241, 241);
523522
}

MotionMark/resources/runner/motionmark.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,18 @@ body.large .detail .large {
541541
background: hsla(0, 0%, 100%, 0.9);
542542
}
543543

544+
#overlay footer {
545+
display: flex;
546+
gap: 10px;
547+
margin-top: 1.5em;
548+
}
549+
550+
#overlay footer button {
551+
flex: 1;
552+
margin: 0;
553+
box-sizing: border-box;
554+
}
555+
544556
@supports (-webkit-backdrop-filter: blur(10px)) {
545557
#overlay {
546558
background: hsla(0, 0%, 100%, 0.7);

MotionMark/resources/runner/motionmark.js

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class BenchmarkRunnerClient {
2727
iterationCount = 1;
2828
options = null;
2929
results = null;
30-
30+
3131
constructor(suites, options)
3232
{
3333
this.options = options;
@@ -133,7 +133,7 @@ class BenchmarkController {
133133

134134
await this.detectFrameRate();
135135
}
136-
136+
137137
async detectFrameRate(progressElement = undefined)
138138
{
139139
let targetFrameRate;
@@ -144,15 +144,15 @@ class BenchmarkController {
144144
}
145145
this.frameRateDeterminationComplete(targetFrameRate);
146146
}
147-
147+
148148
updateUIStrings()
149149
{
150150
document.title = Strings.text.title.replace("%s", Strings.version);
151151
document.querySelectorAll(".version").forEach(function(e) {
152152
e.textContent = Strings.version;
153153
});
154154
}
155-
155+
156156
frameRateDeterminationComplete(frameRate)
157157
{
158158
const frameRateLabel = document.getElementById("frame-rate-label");
@@ -163,7 +163,7 @@ class BenchmarkController {
163163
frameRate = 60;
164164
} else if (frameRate != 60)
165165
labelContent = Strings.text.non60FrameRate.replace("%s", frameRate);
166-
else
166+
else
167167
labelContent = Strings.text.usingFrameRate.replace("%s", frameRate);
168168

169169
frameRateLabel.innerHTML = labelContent;
@@ -288,7 +288,7 @@ class BenchmarkController {
288288

289289
sectionsManager.showSection("test-container");
290290
}
291-
291+
292292
ensureRunnerClient(suites, options)
293293
{
294294
this.runnerClient = new benchmarkRunnerClientClass(suites, options);
@@ -331,6 +331,9 @@ class BenchmarkController {
331331
case 106: // j
332332
benchmarkController.showDebugInfo();
333333
break;
334+
case 100: // d
335+
benchmarkController.downloadDebugInfo();
336+
break;
334337
case 115: // s
335338
benchmarkController.selectResults(event.target);
336339
break;
@@ -380,11 +383,41 @@ class BenchmarkController {
380383
selection.addRange(range);
381384
};
382385

383-
var button = Utilities.createElement("button", {}, container);
384-
button.textContent = "Done";
385-
button.onclick = () => {
386+
const footer = Utilities.createElement("footer", {}, container);
387+
388+
const doneButton = Utilities.createElement("button", {}, footer);
389+
doneButton.textContent = "Done";
390+
doneButton.onclick = () => {
386391
this.hideDebugInfo();
387392
};
393+
394+
const downloadButton = Utilities.createElement("button", {}, footer);
395+
downloadButton.textContent = "Download";
396+
downloadButton.onclick = () => {
397+
this.downloadDebugInfo();
398+
};
399+
}
400+
401+
downloadDebugInfo()
402+
{
403+
const output = {
404+
version: this.runnerClient.scoreCalculator.version,
405+
options: this.runnerClient.scoreCalculator.options,
406+
data: this.runnerClient.scoreCalculator.data
407+
};
408+
const json = JSON.stringify(output, (key, value) => {
409+
if (typeof value === 'number')
410+
return Utilities.toFixedNumber(value, 3);
411+
return value;
412+
}, 1);
413+
const blob = new Blob([json], { type: "application/json" });
414+
const url = URL.createObjectURL(blob);
415+
416+
const a = document.createElement('a');
417+
a.href = url;
418+
a.download = 'motionmark-results.json';
419+
a.click();
420+
URL.revokeObjectURL(url);
388421
}
389422

390423
selectResults(target)

0 commit comments

Comments
 (0)