@@ -52,13 +52,10 @@ function forkAndCallBenchmark(
52
52
benchmarkId : benchmarkInfo . id ,
53
53
benchmarkOptions,
54
54
} ) ;
55
- forked . on (
56
- "message" ,
57
- ( msg : ErrorAndWarning < number | CPUBenchmarkResult | StartupBenchmarkResult > ) => {
55
+ forked . on ( "message" , ( msg : ErrorAndWarning < number | CPUBenchmarkResult | StartupBenchmarkResult > ) => {
58
56
if ( config . LOG_DETAILS ) console . log ( "FORKING: main process got message from child" , msg ) ;
59
57
resolve ( msg ) ;
60
- }
61
- ) ;
58
+ } ) ;
62
59
forked . on ( "close" , ( msg ) => {
63
60
if ( config . LOG_DETAILS ) console . log ( "FORKING: child closed" , msg ) ;
64
61
} ) ;
@@ -185,14 +182,14 @@ async function runBenchmakLoop(
185
182
benchmark : benchmarkInfo ,
186
183
results : results as CPUBenchmarkResult [ ] ,
187
184
type : BenchmarkType . CPU ,
188
- } ) ;
185
+ } ) ;
189
186
} else {
190
187
await writeResults ( benchmarkOptions . resultsDirectory , {
191
188
framework : framework ,
192
189
benchmark : benchmarkInfo ,
193
190
results : results as number [ ] ,
194
191
type : BenchmarkType . MEM ,
195
- } ) ;
192
+ } ) ;
196
193
}
197
194
}
198
195
return { errors, warnings } ;
@@ -231,11 +228,25 @@ async function runBench(
231
228
let result ;
232
229
233
230
if ( benchmarkInfos [ j ] . type == BenchmarkType . STARTUP_MAIN ) {
234
- result = await runBenchmakLoopStartup ( runFrameworks [ i ] , benchmarkInfos [ j ] as StartupBenchmarkInfo , benchmarkOptions )
231
+ result = await runBenchmakLoopStartup (
232
+ runFrameworks [ i ] ,
233
+ benchmarkInfos [ j ] as StartupBenchmarkInfo ,
234
+ benchmarkOptions
235
+ ) ;
235
236
} else if ( benchmarkInfos [ j ] . type == BenchmarkType . CPU ) {
236
- result = await runBenchmakLoop ( runFrameworks [ i ] , benchmarkInfos [ j ] as CPUBenchmarkInfo , benchmarkOptions , plausibilityCheck ) ;
237
+ result = await runBenchmakLoop (
238
+ runFrameworks [ i ] ,
239
+ benchmarkInfos [ j ] as CPUBenchmarkInfo ,
240
+ benchmarkOptions ,
241
+ plausibilityCheck
242
+ ) ;
237
243
} else {
238
- result = await runBenchmakLoop ( runFrameworks [ i ] , benchmarkInfos [ j ] as MemBenchmarkInfo , benchmarkOptions , plausibilityCheck ) ;
244
+ result = await runBenchmakLoop (
245
+ runFrameworks [ i ] ,
246
+ benchmarkInfos [ j ] as MemBenchmarkInfo ,
247
+ benchmarkOptions ,
248
+ plausibilityCheck
249
+ ) ;
239
250
}
240
251
errors = errors . concat ( result . errors ) ;
241
252
warnings = warnings . concat ( result . warnings ) ;
@@ -271,34 +282,34 @@ async function runBench(
271
282
}
272
283
273
284
async function main ( ) {
274
- // FIXME: Clean up args.
275
- // What works: npm run bench keyed/react, npm run bench -- keyed/react, npm run bench -- keyed/react --count 1 --benchmark 01_
276
- // What doesn't work (keyed/react becomes an element of argument benchmark): npm run bench -- --count 1 --benchmark 01_ keyed/react
285
+ // FIXME: Clean up args.
286
+ // What works: npm run bench keyed/react, npm run bench -- keyed/react, npm run bench -- keyed/react --count 1 --benchmark 01_
287
+ // What doesn't work (keyed/react becomes an element of argument benchmark): npm run bench -- --count 1 --benchmark 01_ keyed/react
277
288
278
289
console . error ( "PLEASE MAKE SURE THAT YOUR MOUSE IS OUTSIDE OF THE BROWSER WINDOW - and sorry for shouting :-) " ) ;
279
290
280
- let args : any = yargs ( process . argv )
281
- . usage (
282
- "$0 [--framework Framework1 Framework2 ...] [--benchmark Benchmark1 Benchmark2 ...] [--chromeBinary path] \n or: $0 [directory1] [directory2] .. [directory3]"
283
- )
284
- . help ( "help" )
291
+ let args : any = yargs ( process . argv )
292
+ . usage (
293
+ "$0 [--framework Framework1 Framework2 ...] [--benchmark Benchmark1 Benchmark2 ...] [--chromeBinary path] \n or: $0 [directory1] [directory2] .. [directory3]"
294
+ )
295
+ . help ( "help" )
285
296
. boolean ( "headless" )
286
297
. default ( "headless" , false )
287
- . boolean ( "smoketest" )
298
+ . boolean ( "smoketest" )
288
299
. boolean ( "nothrottling" )
289
300
. default ( "nothrottling" , false )
290
301
. string ( "runner" )
291
302
. default ( "runner" , "puppeteer" )
292
303
. string ( "browser" )
293
304
. default ( "browser" , "chrome" )
294
- . array ( "framework" )
295
- . array ( "benchmark" )
296
- . number ( "count" )
297
- . string ( "chromeBinary" ) . argv ;
305
+ . array ( "framework" )
306
+ . array ( "benchmark" )
307
+ . number ( "count" )
308
+ . string ( "chromeBinary" ) . argv ;
298
309
299
- console . log ( "args" , args ) ;
310
+ console . log ( "args" , args ) ;
300
311
301
- let runner = args . runner ;
312
+ let runner = args . runner ;
302
313
if (
303
314
[
304
315
BenchmarkRunner . WEBDRIVER_CDP ,
@@ -309,64 +320,61 @@ let runner = args.runner;
309
320
] . includes ( runner )
310
321
) {
311
322
console . log ( `INFO: Using ${ runner } benchmark runner` ) ;
312
- config . BENCHMARK_RUNNER = runner ;
313
- } else {
323
+ config . BENCHMARK_RUNNER = runner ;
324
+ } else {
314
325
console . log ( "ERROR: argument driver has illegal value " + runner , [
315
326
BenchmarkRunner . WEBDRIVER_CDP ,
316
327
BenchmarkRunner . WEBDRIVER ,
317
328
BenchmarkRunner . PLAYWRIGHT ,
318
329
BenchmarkRunner . PUPPETEER ,
319
330
] ) ;
320
- process . exit ( 1 ) ;
321
- }
322
- console . log ( "HEADLESS*** " , args . headless ) ;
323
-
324
- let benchmarkOptions : BenchmarkOptions = {
325
- port : 8080 ,
326
- host : "localhost" ,
327
- browser : args . browser ,
328
- remoteDebuggingPort : 9999 ,
329
- chromePort : 9998 ,
330
- headless : args . headless ,
331
- chromeBinaryPath : args . chromeBinary ,
332
- numIterationsForCPUBenchmarks :
333
- config . NUM_ITERATIONS_FOR_BENCHMARK_CPU +
334
- config . NUM_ITERATIONS_FOR_BENCHMARK_CPU_DROP_SLOWEST_COUNT ,
335
- numIterationsForMemBenchmarks : config . NUM_ITERATIONS_FOR_BENCHMARK_MEM ,
336
- numIterationsForStartupBenchmark : config . NUM_ITERATIONS_FOR_BENCHMARK_STARTUP ,
337
- batchSize : 1 ,
338
- resultsDirectory : "results" ,
339
- tracesDirectory : "traces" ,
340
- allowThrottling : ! args . nothrottling ,
341
- } ;
342
-
343
- if ( args . count ) {
344
- benchmarkOptions . numIterationsForCPUBenchmarks = args . count ;
345
- config . NUM_ITERATIONS_FOR_BENCHMARK_CPU_DROP_SLOWEST_COUNT = 0 ;
346
- benchmarkOptions . numIterationsForMemBenchmarks = args . count ;
347
- benchmarkOptions . numIterationsForStartupBenchmark = args . count ;
348
- }
331
+ process . exit ( 1 ) ;
332
+ }
333
+ console . log ( "HEADLESS*** " , args . headless ) ;
334
+
335
+ let benchmarkOptions : BenchmarkOptions = {
336
+ port : 8080 ,
337
+ host : "localhost" ,
338
+ browser : args . browser ,
339
+ remoteDebuggingPort : 9999 ,
340
+ chromePort : 9998 ,
341
+ headless : args . headless ,
342
+ chromeBinaryPath : args . chromeBinary ,
343
+ numIterationsForCPUBenchmarks :
344
+ config . NUM_ITERATIONS_FOR_BENCHMARK_CPU + config . NUM_ITERATIONS_FOR_BENCHMARK_CPU_DROP_SLOWEST_COUNT ,
345
+ numIterationsForMemBenchmarks : config . NUM_ITERATIONS_FOR_BENCHMARK_MEM ,
346
+ numIterationsForStartupBenchmark : config . NUM_ITERATIONS_FOR_BENCHMARK_STARTUP ,
347
+ batchSize : 1 ,
348
+ resultsDirectory : "results" ,
349
+ tracesDirectory : "traces" ,
350
+ allowThrottling : ! args . nothrottling ,
351
+ } ;
352
+
353
+ if ( args . count ) {
354
+ benchmarkOptions . numIterationsForCPUBenchmarks = args . count ;
355
+ config . NUM_ITERATIONS_FOR_BENCHMARK_CPU_DROP_SLOWEST_COUNT = 0 ;
356
+ benchmarkOptions . numIterationsForMemBenchmarks = args . count ;
357
+ benchmarkOptions . numIterationsForStartupBenchmark = args . count ;
358
+ }
349
359
350
- let allArgs = args . _ . length <= 2 ? [ ] : args . _ . slice ( 2 , args . _ . length ) ;
351
- let frameworkArgument = ! args . framework ? allArgs : args . framework ;
352
- console . log ( "args" , args , "allArgs" , allArgs ) ;
360
+ let allArgs = args . _ . length <= 2 ? [ ] : args . _ . slice ( 2 , args . _ . length ) ;
361
+ let frameworkArgument = ! args . framework ? allArgs : args . framework ;
362
+ console . log ( "args" , args , "allArgs" , allArgs ) ;
353
363
354
- if ( process . env . HOST ) {
355
- benchmarkOptions . host = process . env . HOST ;
356
- console . log ( `INFO: Using host ${ benchmarkOptions . host } instead of localhost` ) ;
357
- }
358
- console . log ( "benchmarkOptions" , benchmarkOptions ) ;
364
+ if ( process . env . HOST ) {
365
+ benchmarkOptions . host = process . env . HOST ;
366
+ console . log ( `INFO: Using host ${ benchmarkOptions . host } instead of localhost` ) ;
367
+ }
368
+ console . log ( "benchmarkOptions" , benchmarkOptions ) ;
359
369
360
- let runBenchmarksArgs : string [ ] =
361
- args . benchmark && args . benchmark . length > 0 ? args . benchmark : [ "" ] ;
370
+ let runBenchmarksArgs : string [ ] = args . benchmark && args . benchmark . length > 0 ? args . benchmark : [ "" ] ;
362
371
let runBenchmarks : Array < BenchmarkInfo > = benchmarkInfos . filter (
363
372
( b ) =>
364
373
// afterframe currently only targets CPU benchmarks
365
- ( config . BENCHMARK_RUNNER !== BenchmarkRunner . WEBDRIVER_AFTERFRAME ||
366
- b . type == BenchmarkType . CPU ) &&
367
- runBenchmarksArgs . some ( ( name ) => b . id . toLowerCase ( ) . indexOf ( name ) > - 1 )
374
+ ( config . BENCHMARK_RUNNER !== BenchmarkRunner . WEBDRIVER_AFTERFRAME || b . type == BenchmarkType . CPU ) &&
375
+ runBenchmarksArgs . some ( ( name ) => b . id . toLowerCase ( ) . indexOf ( name ) > - 1 )
368
376
) ;
369
-
377
+
370
378
let runFrameworks : FrameworkData [ ] ;
371
379
let matchesDirectoryArg = ( directoryName : string ) =>
372
380
frameworkArgument . length == 0 || frameworkArgument . some ( ( arg : string ) => arg == directoryName ) ;
@@ -389,11 +397,9 @@ console.log("benchmarkOptions", benchmarkOptions);
389
397
}
390
398
if ( config . BENCHMARK_RUNNER == BenchmarkRunner . WEBDRIVER_AFTERFRAME ) {
391
399
benchmarkOptions . resultsDirectory = "results_client_" + benchmarkOptions . browser ;
392
- }
393
- if ( ! fs . existsSync ( benchmarkOptions . resultsDirectory ) )
394
- fs . mkdirSync ( benchmarkOptions . resultsDirectory ) ;
395
- if ( ! fs . existsSync ( benchmarkOptions . tracesDirectory ) )
396
- fs . mkdirSync ( benchmarkOptions . tracesDirectory ) ;
400
+ }
401
+ if ( ! fs . existsSync ( benchmarkOptions . resultsDirectory ) ) fs . mkdirSync ( benchmarkOptions . resultsDirectory ) ;
402
+ if ( ! fs . existsSync ( benchmarkOptions . tracesDirectory ) ) fs . mkdirSync ( benchmarkOptions . tracesDirectory ) ;
397
403
398
404
if ( args . help ) {
399
405
// yargs.showHelp();
0 commit comments