@@ -39,17 +39,16 @@ globalThis.testWorstCaseCountMap ??= new Map();
39
39
globalThis . dumpJSONResults ??= false ;
40
40
globalThis . testList ??= undefined ;
41
41
globalThis . startDelay ??= undefined ;
42
-
43
- let shouldReport = false ;
42
+ globalThis . shouldReport ??= false ;
44
43
45
44
function getIntParam ( urlParams , key ) {
46
45
if ( ! urlParams . has ( key ) )
47
46
return undefined
48
47
const rawValue = urlParams . get ( key ) ;
49
48
const value = parseInt ( rawValue ) ;
50
49
if ( value <= 0 )
51
- throw new Error ( `Expected positive value for ${ key } , but got ${ rawValue } ` )
52
- return value
50
+ throw new Error ( `Expected positive value for ${ key } , but got ${ rawValue } ` ) ;
51
+ return value ;
53
52
}
54
53
55
54
function getTestListParam ( urlParams , key ) {
@@ -60,16 +59,20 @@ function getTestListParam(urlParams, key) {
60
59
61
60
if ( typeof ( URLSearchParams ) !== "undefined" ) {
62
61
const urlParameters = new URLSearchParams ( window . location . search ) ;
63
- shouldReport = urlParameters . has ( 'report' ) && urlParameters . get ( 'report' ) . toLowerCase ( ) == 'true' ;
64
- globalThis . startDelay = getIntParam ( urlParameters , "startDelay" ) ;
65
- if ( shouldReport && ! globalThis . startDelay )
62
+ if ( urlParameters . has ( "report" ) )
63
+ globalThis . shouldReport = urlParameters . get ( "report" ) . toLowerCase ( ) == "true" ;
64
+ if ( urlParameters . has ( "startDelay" ) )
65
+ globalThis . startDelay = getIntParam ( urlParameters , "startDelay" ) ;
66
+ if ( globalThis . shouldReport && ! globalThis . startDelay )
66
67
globalThis . startDelay = 4000 ;
67
68
if ( urlParameters . has ( "tag" ) )
68
69
globalThis . testList = getTestListParam ( urlParameters , "tag" ) ;
69
70
if ( urlParameters . has ( "test" ) )
70
71
globalThis . testList = getTestListParam ( urlParameters , "test" ) ;
71
- globalThis . testIterationCount = getIntParam ( urlParameters , "iterationCount" ) ;
72
- globalThis . testWorstCaseCount = getIntParam ( urlParameters , "worstCaseCount" ) ;
72
+ if ( urlParameters . has ( "iterationCount" ) )
73
+ globalThis . testIterationCount = getIntParam ( urlParameters , "iterationCount" ) ;
74
+ if ( urlParameters . has ( "worstCaseCount" ) )
75
+ globalThis . testWorstCaseCount = getIntParam ( urlParameters , "worstCaseCount" ) ;
73
76
}
74
77
75
78
// Used for the promise representing the current benchmark run.
@@ -549,7 +552,7 @@ class Driver {
549
552
if ( ! isInBrowser )
550
553
return ;
551
554
552
- if ( ! shouldReport )
555
+ if ( ! globalThis . shouldReport )
553
556
return ;
554
557
555
558
const content = this . resultsJSON ( ) ;
0 commit comments