@@ -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