@@ -30,58 +30,7 @@ const measureTotalTimeAsSubtest = false; // Once we move to preloading all resou
30
30
const defaultIterationCount = 120 ;
31
31
const defaultWorstCaseCount = 4 ;
32
32
33
- globalThis . performance ??= Date ;
34
- globalThis . RAMification ??= false ;
35
- globalThis . testIterationCount ??= undefined ;
36
- globalThis . testIterationCountMap ??= new Map ( ) ;
37
- globalThis . testWorstCaseCount ??= undefined ;
38
- globalThis . testWorstCaseCountMap ??= new Map ( ) ;
39
- globalThis . dumpJSONResults ??= false ;
40
- globalThis . testList ??= undefined ;
41
- globalThis . startDelay ??= undefined ;
42
- globalThis . shouldReport ??= false ;
43
- globalThis . prefetchResources ??= true ;
44
-
45
- function getIntParam ( urlParams , key ) {
46
- const rawValue = urlParams . get ( key ) ;
47
- const value = parseInt ( rawValue ) ;
48
- if ( value <= 0 )
49
- throw new Error ( `Expected positive value for ${ key } , but got ${ rawValue } ` ) ;
50
- return value ;
51
- }
52
-
53
- function getBoolParam ( urlParams , key ) {
54
- const rawValue = urlParams . get ( key ) . toLowerCase ( )
55
- return ! ( rawValue === "false" || rawValue === "0" )
56
- }
57
-
58
- function getTestListParam ( urlParams , key ) {
59
- if ( globalThis . testList ?. length )
60
- throw new Error ( `Overriding previous testList=${ globalThis . testList . join ( ) } with ${ key } url-parameter.` ) ;
61
- return urlParams . getAll ( key ) ;
62
- }
63
-
64
- if ( typeof ( URLSearchParams ) !== "undefined" ) {
65
- const urlParameters = new URLSearchParams ( window . location . search ) ;
66
- if ( urlParameters . has ( "report" ) )
67
- globalThis . shouldReport = urlParameters . get ( "report" ) . toLowerCase ( ) == "true" ;
68
- if ( urlParameters . has ( "startDelay" ) )
69
- globalThis . startDelay = getIntParam ( urlParameters , "startDelay" ) ;
70
- if ( globalThis . shouldReport && ! globalThis . startDelay )
71
- globalThis . startDelay = 4000 ;
72
- if ( urlParameters . has ( "tag" ) )
73
- globalThis . testList = getTestListParam ( urlParameters , "tag" ) ;
74
- if ( urlParameters . has ( "test" ) )
75
- globalThis . testList = getTestListParam ( urlParameters , "test" ) ;
76
- if ( urlParameters . has ( "iterationCount" ) )
77
- globalThis . testIterationCount = getIntParam ( urlParameters , "iterationCount" ) ;
78
- if ( urlParameters . has ( "worstCaseCount" ) )
79
- globalThis . testWorstCaseCount = getIntParam ( urlParameters , "worstCaseCount" ) ;
80
- if ( urlParameters . has ( "prefetchResources" ) )
81
- globalThis . prefetchResources = getBoolParam ( urlParameters , "prefetchResources" ) ;
82
- }
83
-
84
- if ( ! globalThis . prefetchResources )
33
+ if ( ! JetStreamParams . prefetchResources )
85
34
console . warn ( "Disabling resource prefetching!" ) ;
86
35
87
36
// Used for the promise representing the current benchmark run.
@@ -110,20 +59,20 @@ function displayCategoryScores() {
110
59
}
111
60
112
61
function getIterationCount ( plan ) {
113
- if ( testIterationCountMap . has ( plan . name ) )
114
- return testIterationCountMap . get ( plan . name ) ;
115
- if ( globalThis . testIterationCount )
116
- return globalThis . testIterationCount ;
62
+ if ( JetStreamParams . testIterationCountMap . has ( plan . name ) )
63
+ return JetStreamParams . testIterationCountMap . get ( plan . name ) ;
64
+ if ( JetStreamParams . testIterationCount )
65
+ return JetStreamParams . testIterationCount ;
117
66
if ( plan . iterations )
118
67
return plan . iterations ;
119
68
return defaultIterationCount ;
120
69
}
121
70
122
71
function getWorstCaseCount ( plan ) {
123
- if ( testWorstCaseCountMap . has ( plan . name ) )
124
- return testWorstCaseCountMap . get ( plan . name ) ;
125
- if ( globalThis . testWorstCaseCount )
126
- return globalThis . testWorstCaseCount ;
72
+ if ( JetStreamParams . testWorstCaseCountMap . has ( plan . name ) )
73
+ return JetStreamParams . testWorstCaseCountMap . get ( plan . name ) ;
74
+ if ( JetStreamParams . testWorstCaseCount )
75
+ return JetStreamParams . testWorstCaseCount ;
127
76
if ( plan . worstCaseCount )
128
77
return plan . worstCaseCount ;
129
78
return defaultWorstCaseCount ;
@@ -201,7 +150,7 @@ class ShellFileLoader {
201
150
// share common code.
202
151
load ( url ) {
203
152
console . assert ( ! isInBrowser ) ;
204
- if ( ! globalThis . prefetchResources )
153
+ if ( ! JetStreamParams . prefetchResources )
205
154
return `load("${ url } ");`
206
155
207
156
if ( this . requests . has ( url ) ) {
@@ -240,7 +189,7 @@ class Driver {
240
189
if ( isInBrowser ) {
241
190
statusElement = document . getElementById ( "status" ) ;
242
191
statusElement . innerHTML = `<label>Running...</label>` ;
243
- } else if ( ! dumpJSONResults )
192
+ } else if ( ! JetStreamParams . dumpJSONResults )
244
193
console . log ( "Starting JetStream3" ) ;
245
194
246
195
performance . mark ( "update-ui-start" ) ;
@@ -260,7 +209,7 @@ class Driver {
260
209
performance . mark ( "update-ui" ) ;
261
210
benchmark . updateUIAfterRun ( ) ;
262
211
263
- if ( isInBrowser && globalThis . prefetchResources ) {
212
+ if ( isInBrowser && JetStreamParams . prefetchResources ) {
264
213
const cache = JetStream . blobDataCache ;
265
214
for ( const file of benchmark . files ) {
266
215
const blobData = cache [ file ] ;
@@ -276,7 +225,7 @@ class Driver {
276
225
if ( measureTotalTimeAsSubtest ) {
277
226
if ( isInBrowser )
278
227
document . getElementById ( "benchmark-total-time-score" ) . innerHTML = uiFriendlyNumber ( totalTime ) ;
279
- else if ( ! dumpJSONResults )
228
+ else if ( ! JetStreamParams . dumpJSONResults )
280
229
console . log ( "Total time:" , uiFriendlyNumber ( totalTime ) ) ;
281
230
allScores . push ( totalTime ) ;
282
231
}
@@ -314,7 +263,7 @@ class Driver {
314
263
if ( showScoreDetails )
315
264
displayCategoryScores ( ) ;
316
265
statusElement . innerHTML = "" ;
317
- } else if ( ! dumpJSONResults ) {
266
+ } else if ( ! JetStreamParams . dumpJSONResults ) {
318
267
console . log ( "\n" ) ;
319
268
for ( let [ category , scores ] of categoryScores )
320
269
console . log ( `${ category } : ${ uiFriendlyScore ( geomeanScore ( scores ) ) } ` ) ;
@@ -404,8 +353,8 @@ class Driver {
404
353
this . isReady = true ;
405
354
if ( isInBrowser ) {
406
355
globalThis . dispatchEvent ( new Event ( "JetStreamReady" ) ) ;
407
- if ( typeof ( globalThis . startDelay ) !== "undefined" ) {
408
- setTimeout ( ( ) => this . start ( ) , globalThis . startDelay ) ;
356
+ if ( typeof ( JetStreamParams . startDelay ) !== "undefined" ) {
357
+ setTimeout ( ( ) => this . start ( ) , JetStreamParams . startDelay ) ;
409
358
}
410
359
}
411
360
}
@@ -510,7 +459,7 @@ class Driver {
510
459
511
460
dumpJSONResultsIfNeeded ( )
512
461
{
513
- if ( dumpJSONResults ) {
462
+ if ( JetStreamParams . dumpJSONResults ) {
514
463
console . log ( "\n" ) ;
515
464
console . log ( this . resultsJSON ( ) ) ;
516
465
console . log ( "\n" ) ;
@@ -529,7 +478,7 @@ class Driver {
529
478
if ( ! isInBrowser )
530
479
return ;
531
480
532
- if ( ! globalThis . shouldReport )
481
+ if ( ! JetStreamParams . shouldReport )
533
482
return ;
534
483
535
484
const content = this . resultsJSON ( ) ;
@@ -799,17 +748,17 @@ class Benchmark {
799
748
if ( this . plan . deterministicRandom )
800
749
code += `Math.random.__resetSeed();` ;
801
750
802
- if ( globalThis . customPreIterationCode )
803
- code += customPreIterationCode ;
751
+ if ( JetStreamParams . customPreIterationCode )
752
+ code += JetStreamParams . customPreIterationCode ;
804
753
805
754
return code ;
806
755
}
807
756
808
757
get postIterationCode ( ) {
809
758
let code = "" ;
810
759
811
- if ( globalThis . customPostIterationCode )
812
- code += customPostIterationCode ;
760
+ if ( JetStreamParams . customPostIterationCode )
761
+ code += JetStreamParams . customPostIterationCode ;
813
762
814
763
return code ;
815
764
}
@@ -843,7 +792,7 @@ class Benchmark {
843
792
} else {
844
793
const cache = JetStream . blobDataCache ;
845
794
for ( const file of this . plan . files ) {
846
- scripts . addWithURL ( globalThis . prefetchResources ? cache [ file ] . blobURL : file ) ;
795
+ scripts . addWithURL ( JetStreamParams . prefetchResources ? cache [ file ] . blobURL : file ) ;
847
796
}
848
797
}
849
798
@@ -857,7 +806,7 @@ class Benchmark {
857
806
performance . mark ( this . name ) ;
858
807
this . startTime = performance . now ( ) ;
859
808
860
- if ( RAMification )
809
+ if ( JetStreamParams . RAMification )
861
810
resetMemoryPeak ( ) ;
862
811
863
812
let magicFrame ;
@@ -877,7 +826,7 @@ class Benchmark {
877
826
this . endTime = performance . now ( ) ;
878
827
performance . measure ( this . name , this . name ) ;
879
828
880
- if ( RAMification ) {
829
+ if ( JetStreamParams . RAMification ) {
881
830
const memoryFootprint = MemoryFootprint ( ) ;
882
831
this . currentFootprint = memoryFootprint . current ;
883
832
this . peakFootprint = memoryFootprint . peak ;
@@ -894,7 +843,7 @@ class Benchmark {
894
843
895
844
async doLoadBlob ( resource ) {
896
845
const blobData = JetStream . blobDataCache [ resource ] ;
897
- if ( ! globalThis . prefetchResources ) {
846
+ if ( ! JetStreamParams . prefetchResources ) {
898
847
blobData . blobURL = resource ;
899
848
return blobData ;
900
849
}
@@ -1062,7 +1011,7 @@ class Benchmark {
1062
1011
}
1063
1012
1064
1013
updateUIBeforeRun ( ) {
1065
- if ( ! dumpJSONResults )
1014
+ if ( ! JetStreamParams . dumpJSONResults )
1066
1015
console . log ( `Running ${ this . name } :` ) ;
1067
1016
if ( isInBrowser )
1068
1017
this . updateUIBeforeRunInBrowser ( ) ;
@@ -1081,7 +1030,7 @@ class Benchmark {
1081
1030
const scoreEntries = Object . entries ( this . allScores ( ) ) ;
1082
1031
if ( isInBrowser )
1083
1032
this . updateUIAfterRunInBrowser ( scoreEntries ) ;
1084
- if ( dumpJSONResults )
1033
+ if ( JetStreamParams . dumpJSONResults )
1085
1034
return ;
1086
1035
this . updateConsoleAfterRun ( scoreEntries ) ;
1087
1036
}
@@ -1129,7 +1078,7 @@ class Benchmark {
1129
1078
for ( let [ name , value ] of scoreEntries ) {
1130
1079
console . log ( ` ${ name } :` , uiFriendlyScore ( value ) ) ;
1131
1080
}
1132
- if ( RAMification ) {
1081
+ if ( JetStreamParams . RAMification ) {
1133
1082
console . log ( " Current Footprint:" , uiFriendlyNumber ( this . currentFootprint ) ) ;
1134
1083
console . log ( " Peak Footprint:" , uiFriendlyNumber ( this . peakFootprint ) ) ;
1135
1084
}
@@ -2803,8 +2752,8 @@ const defaultDisabledTags = [];
2803
2752
if ( ! isInBrowser )
2804
2753
defaultDisabledTags . push ( "WorkerTests" ) ;
2805
2754
2806
- if ( globalThis . testList ? .length ) {
2807
- benchmarks = processTestList ( globalThis . testList ) ;
2755
+ if ( JetStreamParams . testList . length ) {
2756
+ benchmarks = processTestList ( JetStreamParams . testList ) ;
2808
2757
} else {
2809
2758
benchmarks = findBenchmarksByTag ( "Default" , defaultDisabledTags )
2810
2759
}
0 commit comments