From 80f97b2b2ff755b6775b9bb5cdd02a3e4a19e822 Mon Sep 17 00:00:00 2001 From: Sunny Sachanandani Date: Wed, 6 Aug 2025 13:29:19 -0700 Subject: [PATCH] Add button and shortcut to download results JSON --- MotionMark/developer.html | 1 + .../resources/debug-runner/motionmark.css | 1 - MotionMark/resources/runner/motionmark.css | 12 +++++ MotionMark/resources/runner/motionmark.js | 51 +++++++++++++++---- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/MotionMark/developer.html b/MotionMark/developer.html index b2de742..0239a83 100644 --- a/MotionMark/developer.html +++ b/MotionMark/developer.html @@ -158,6 +158,7 @@

MotionMark score

'j': Show JSON results
+ 'd': Download JSON results
's': Select various results for copy/paste (use repeatedly to cycle)

diff --git a/MotionMark/resources/debug-runner/motionmark.css b/MotionMark/resources/debug-runner/motionmark.css index fe1a0c4..fa83391 100644 --- a/MotionMark/resources/debug-runner/motionmark.css +++ b/MotionMark/resources/debug-runner/motionmark.css @@ -517,7 +517,6 @@ body.showing-test-container.tiles-classic { } #overlay button { - margin: 2em auto; border-color: rgb(241, 241, 241); color: rgb(241, 241, 241); } diff --git a/MotionMark/resources/runner/motionmark.css b/MotionMark/resources/runner/motionmark.css index 0ca5d75..1fcfa13 100644 --- a/MotionMark/resources/runner/motionmark.css +++ b/MotionMark/resources/runner/motionmark.css @@ -541,6 +541,18 @@ body.large .detail .large { background: hsla(0, 0%, 100%, 0.9); } +#overlay footer { + display: flex; + gap: 10px; + margin-top: 1.5em; +} + +#overlay footer button { + flex: 1; + margin: 0; + box-sizing: border-box; +} + @supports (-webkit-backdrop-filter: blur(10px)) { #overlay { background: hsla(0, 0%, 100%, 0.7); diff --git a/MotionMark/resources/runner/motionmark.js b/MotionMark/resources/runner/motionmark.js index 193e212..d650878 100644 --- a/MotionMark/resources/runner/motionmark.js +++ b/MotionMark/resources/runner/motionmark.js @@ -27,7 +27,7 @@ class BenchmarkRunnerClient { iterationCount = 1; options = null; results = null; - + constructor(suites, options) { this.options = options; @@ -133,7 +133,7 @@ class BenchmarkController { await this.detectFrameRate(); } - + async detectFrameRate(progressElement = undefined) { let targetFrameRate; @@ -144,7 +144,7 @@ class BenchmarkController { } this.frameRateDeterminationComplete(targetFrameRate); } - + updateUIStrings() { document.title = Strings.text.title.replace("%s", Strings.version); @@ -152,7 +152,7 @@ class BenchmarkController { e.textContent = Strings.version; }); } - + frameRateDeterminationComplete(frameRate) { const frameRateLabel = document.getElementById("frame-rate-label"); @@ -163,7 +163,7 @@ class BenchmarkController { frameRate = 60; } else if (frameRate != 60) labelContent = Strings.text.non60FrameRate.replace("%s", frameRate); - else + else labelContent = Strings.text.usingFrameRate.replace("%s", frameRate); frameRateLabel.innerHTML = labelContent; @@ -288,7 +288,7 @@ class BenchmarkController { sectionsManager.showSection("test-container"); } - + ensureRunnerClient(suites, options) { this.runnerClient = new benchmarkRunnerClientClass(suites, options); @@ -331,6 +331,9 @@ class BenchmarkController { case 106: // j benchmarkController.showDebugInfo(); break; + case 100: // d + benchmarkController.downloadDebugInfo(); + break; case 115: // s benchmarkController.selectResults(event.target); break; @@ -380,11 +383,41 @@ class BenchmarkController { selection.addRange(range); }; - var button = Utilities.createElement("button", {}, container); - button.textContent = "Done"; - button.onclick = () => { + const footer = Utilities.createElement("footer", {}, container); + + const doneButton = Utilities.createElement("button", {}, footer); + doneButton.textContent = "Done"; + doneButton.onclick = () => { this.hideDebugInfo(); }; + + const downloadButton = Utilities.createElement("button", {}, footer); + downloadButton.textContent = "Download"; + downloadButton.onclick = () => { + this.downloadDebugInfo(); + }; + } + + downloadDebugInfo() + { + const output = { + version: this.runnerClient.scoreCalculator.version, + options: this.runnerClient.scoreCalculator.options, + data: this.runnerClient.scoreCalculator.data + }; + const json = JSON.stringify(output, (key, value) => { + if (typeof value === 'number') + return Utilities.toFixedNumber(value, 3); + return value; + }, 1); + const blob = new Blob([json], { type: "application/json" }); + const url = URL.createObjectURL(blob); + + const a = document.createElement('a'); + a.href = url; + a.download = 'motionmark-results.json'; + a.click(); + URL.revokeObjectURL(url); } selectResults(target)