@@ -201,11 +201,13 @@ const fileLoader = (function() {
201
201
} ) ( ) ;
202
202
203
203
class Driver {
204
- constructor ( ) {
204
+ constructor ( benchmarks ) {
205
205
this . isReady = false ;
206
206
this . isDone = false ;
207
207
this . errors = [ ] ;
208
- this . benchmarks = new Set ( ) ;
208
+ // Make benchmark list unique and sort it.
209
+ this . benchmarks = Array . from ( new Set ( benchmarks ) ) ;
210
+ this . benchmarks . sort ( ( a , b ) => a . plan . name . toLowerCase ( ) < b . plan . name . toLowerCase ( ) ? 1 : - 1 ) ;
209
211
// TODO: Cleanup / remove / merge `blobDataCache` and `loadCache` vs.
210
212
// the global `fileLoader` cache.
211
213
this . blobDataCache = { } ;
@@ -216,36 +218,6 @@ class Driver {
216
218
this . counter . failedPreloadResources = 0 ;
217
219
}
218
220
219
- enableBenchmark ( benchmark ) {
220
- // TODO: Remove, make `this.benchmarks` immutable and set it once in the
221
- // ctor instead of this and the global `addBenchmarksBy*` functions.
222
- this . benchmarks . add ( benchmark ) ;
223
- }
224
-
225
- enableBenchmarksByName ( name ) {
226
- const benchmark = benchmarksByName . get ( name . toLowerCase ( ) ) ;
227
-
228
- if ( ! benchmark )
229
- throw new Error ( `Couldn't find benchmark named "${ name } "` ) ;
230
-
231
- this . enableBenchmark ( benchmark ) ;
232
- }
233
-
234
- enableBenchmarksByTag ( tag , excludeTags ) {
235
- const benchmarks = benchmarksByTag . get ( tag . toLowerCase ( ) ) ;
236
-
237
- if ( ! benchmarks ) {
238
- const validTags = Array . from ( benchmarksByTag . keys ( ) ) . join ( ", " ) ;
239
- throw new Error ( `Couldn't find tag named: ${ tag } .\n Choices are ${ validTags } ` ) ;
240
- }
241
-
242
- for ( const benchmark of benchmarks ) {
243
- if ( excludeTags && benchmark . hasAnyTag ( ...excludeTags ) )
244
- continue
245
- this . enableBenchmark ( benchmark ) ;
246
- }
247
- }
248
-
249
221
async start ( ) {
250
222
let statusElement = false ;
251
223
let summaryElement = false ;
@@ -451,15 +423,9 @@ class Driver {
451
423
} ) ;
452
424
}
453
425
454
- initializeBenchmarks ( ) {
455
- this . benchmarks = Array . from ( this . benchmarks ) ;
456
- this . benchmarks . sort ( ( a , b ) => a . plan . name . toLowerCase ( ) < b . plan . name . toLowerCase ( ) ? 1 : - 1 ) ;
457
- }
458
-
459
426
async initialize ( ) {
460
427
if ( isInBrowser )
461
428
window . addEventListener ( "error" , ( e ) => this . pushError ( "driver startup" , e . error ) ) ;
462
- this . initializeBenchmarks ( ) ;
463
429
await this . prefetchResources ( ) ;
464
430
this . prepareToRun ( ) ;
465
431
this . isReady = true ;
@@ -2273,34 +2239,62 @@ for (const benchmark of BENCHMARKS) {
2273
2239
}
2274
2240
}
2275
2241
2276
- this . JetStream = new Driver ( ) ;
2277
-
2278
2242
2279
2243
function processTestList ( testList )
2280
2244
{
2281
2245
let benchmarkNames = [ ] ;
2246
+ let benchmarks = [ ] ;
2282
2247
2283
2248
if ( testList instanceof Array )
2284
2249
benchmarkNames = testList ;
2285
2250
else
2286
2251
benchmarkNames = testList . split ( / [ \s , ] / ) ;
2287
2252
2288
- for ( let name of benchmarkNames ) {
2289
- name = name . toLowerCase ( ) ;
2253
+ for ( const name of benchmarkNames ) {
2290
2254
if ( benchmarksByTag . has ( name ) )
2291
- globalThis . JetStream . enableBenchmarksByTag ( name ) ;
2255
+ benchmarks . push ( ... findBenchmarksByTag ( name ) ) ;
2292
2256
else
2293
- globalThis . JetStream . enableBenchmarksByName ( name ) ;
2257
+ benchmarks . push ( findBenchmarkByName ( name ) ) ;
2294
2258
}
2259
+ return benchmarks ;
2260
+ }
2261
+
2262
+
2263
+ function findBenchmarkByName ( name ) {
2264
+ const benchmark = benchmarksByName . get ( name . toLowerCase ( ) ) ;
2265
+
2266
+ if ( ! benchmark )
2267
+ throw new Error ( `Couldn't find benchmark named "${ name } "` ) ;
2268
+
2269
+ return benchmark ;
2295
2270
}
2296
2271
2272
+
2273
+ function findBenchmarksByTag ( tag , excludeTags ) {
2274
+ let benchmarks = benchmarksByTag . get ( tag . toLowerCase ( ) ) ;
2275
+ if ( ! benchmarks ) {
2276
+ const validTags = Array . from ( benchmarksByTag . keys ( ) ) . join ( ", " ) ;
2277
+ throw new Error ( `Couldn't find tag named: ${ tag } .\n Choices are ${ validTags } ` ) ;
2278
+ }
2279
+ if ( excludeTags ) {
2280
+ benchmarks = benchmarks . filter ( benchmark => {
2281
+ return ! benchmark . hasAnyTag ( ...excludeTags ) ;
2282
+ } ) ;
2283
+ }
2284
+ return benchmarks ;
2285
+ }
2286
+
2287
+
2288
+ let benchmarks = [ ] ;
2297
2289
const defaultDisabledTags = [ ] ;
2298
2290
// FIXME: add better support to run Worker tests in shells.
2299
2291
if ( ! isInBrowser )
2300
2292
defaultDisabledTags . push ( "WorkerTests" ) ;
2301
2293
2302
2294
if ( globalThis . testList ?. length ) {
2303
- processTestList ( globalThis . testList ) ;
2295
+ benchmarks = processTestList ( globalThis . testList ) ;
2304
2296
} else {
2305
- globalThis . JetStream . enableBenchmarksByTag ( "Default" , defaultDisabledTags )
2297
+ benchmarks = findBenchmarksByTag ( "Default" , defaultDisabledTags )
2306
2298
}
2299
+
2300
+ this . JetStream = new Driver ( benchmarks ) ;
0 commit comments