@@ -277,6 +277,31 @@ function seededHashRandomNumberGenerator(a) {
277
277
} ;
278
278
}
279
279
280
+ class WakeLock {
281
+ #wakeLockSentinel = undefined ;
282
+ async request ( ) {
283
+ if ( ! navigator . wakeLock )
284
+ return ;
285
+ try {
286
+ this . #wakeLockSentinel = await navigator . wakeLock . request ( "screen" ) ;
287
+ } catch ( err ) {
288
+ console . error ( `${ err . name } , ${ err . message } ` ) ;
289
+ }
290
+ }
291
+
292
+ async release ( ) {
293
+ if ( ! this . #wakeLockSentinel)
294
+ return ;
295
+ try {
296
+ await this . #wakeLockSentinel. release ( ) ;
297
+ } catch ( err ) {
298
+ console . error ( `${ err . name } , ${ err . message } ` ) ;
299
+ } finally {
300
+ this . #wakeLockSentinel = undefined ;
301
+ }
302
+ }
303
+ }
304
+
280
305
export class BenchmarkRunner {
281
306
constructor ( suites , client ) {
282
307
this . _suites = suites ;
@@ -288,6 +313,7 @@ export class BenchmarkRunner {
288
313
this . _iterationCount = params . iterationCount ;
289
314
if ( params . shuffleSeed !== "off" )
290
315
this . _suiteOrderRandomNumberGenerator = seededHashRandomNumberGenerator ( params . shuffleSeed ) ;
316
+ this . _wakeLock = new WakeLock ( ) ;
291
317
}
292
318
293
319
async runMultipleIterations ( iterationCount ) {
@@ -350,6 +376,7 @@ export class BenchmarkRunner {
350
376
351
377
async _prepareAllSuites ( ) {
352
378
this . _measuredValues = { tests : { } , total : 0 , mean : NaN , geomean : NaN , score : NaN } ;
379
+ await this . _wakeLock . request ( ) ;
353
380
354
381
const prepareStartLabel = "runner-prepare-start" ;
355
382
const prepareEndLabel = "runner-prepare-end" ;
@@ -404,6 +431,7 @@ export class BenchmarkRunner {
404
431
await this . _finalize ( ) ;
405
432
performance . mark ( finalizeEndLabel ) ;
406
433
performance . measure ( "runner-finalize" , finalizeStartLabel , finalizeEndLabel ) ;
434
+ await this . _wakeLock . release ( ) ;
407
435
}
408
436
409
437
async runSuite ( suite ) {
0 commit comments