Skip to content

Commit cdda051

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

2 files changed

Lines changed: 35 additions & 3 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/runner/motionmark.js

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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,39 @@ class BenchmarkController {
380383
selection.addRange(range);
381384
};
382385

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

390421
selectResults(target)

0 commit comments

Comments
 (0)