@@ -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,39 @@ class BenchmarkController {
380383 selection . addRange ( range ) ;
381384 } ;
382385
383- var button = Utilities . createElement ( "button" , { } , container ) ;
384- button . textContent = "Done" ;
385- button . onclick = ( ) => {
386+ const doneButton = Utilities . createElement ( "button" , { } , container ) ;
387+ doneButton . textContent = "Done" ;
388+ doneButton . onclick = ( ) => {
386389 this . hideDebugInfo ( ) ;
387390 } ;
391+
392+ const downloadButton = Utilities . createElement ( "button" , { } , container ) ;
393+ downloadButton . textContent = "Download" ;
394+ downloadButton . onclick = ( ) => {
395+ this . downloadDebugInfo ( ) ;
396+ } ;
397+ }
398+
399+ downloadDebugInfo ( )
400+ {
401+ const output = {
402+ version : this . runnerClient . scoreCalculator . version ,
403+ options : this . runnerClient . scoreCalculator . options ,
404+ data : this . runnerClient . scoreCalculator . data
405+ } ;
406+ const json = JSON . stringify ( output , ( key , value ) => {
407+ if ( typeof value === 'number' )
408+ return Utilities . toFixedNumber ( value , 3 ) ;
409+ return value ;
410+ } , 1 ) ;
411+ const blob = new Blob ( [ json ] , { type : "application/json" } ) ;
412+ const url = URL . createObjectURL ( blob ) ;
413+
414+ const 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