1+ import  { args }  from  './benchmarkArgs.js' ; 
2+ import  {  BenchmarkOptions ,  BENCHMARK_RUNNER ,  config ,  ErrorAndWarning ,  FrameworkData ,  initializeFrameworks  }  from  "./common.js" ; 
13import  {  fork  }  from  "child_process" ; 
24import  *  as  fs  from  "fs" ; 
3- import  yargs  from  'yargs' ; 
45import  {  BenchmarkInfo ,  benchmarkInfos ,  BenchmarkType ,  CPUBenchmarkInfo ,  MemBenchmarkInfo ,  StartupBenchmarkInfo  }  from  "./benchmarksCommon.js" ; 
56import  {  StartupBenchmarkResult  }  from  "./benchmarksLighthouse.js" ; 
6- import  {  BenchmarkOptions ,  BENCHMARK_RUNNER ,  config ,  ErrorAndWarning ,  FrameworkData ,  initializeFrameworks  }  from  "./common.js" ; 
77import  {  writeResults  }  from  "./writeResults.js" ; 
88
99function  forkAndCallBenchmark ( 
1010  framework : FrameworkData , 
1111  benchmarkInfo : BenchmarkInfo , 
1212  benchmarkOptions : BenchmarkOptions 
13- ) : Promise < ErrorAndWarning >  { 
13+ ) : Promise < ErrorAndWarning < number | StartupBenchmarkResult > >  { 
1414  return  new  Promise ( ( resolve ,  reject )  =>  { 
1515    let  forkedRunner  =  null ; 
1616    if  ( benchmarkInfo . type  ===  BenchmarkType . STARTUP_MAIN )  { 
@@ -35,7 +35,7 @@ function forkAndCallBenchmark(
3535      benchmarkId : benchmarkInfo . id , 
3636      benchmarkOptions, 
3737    } ) ; 
38-     forked . on ( "message" ,  ( msg : ErrorAndWarning )  =>  { 
38+     forked . on ( "message" ,  ( msg : ErrorAndWarning < number | StartupBenchmarkResult > )  =>  { 
3939      if  ( config . LOG_DETAILS )  console . log ( "FORKING: main process got message from child" ,  msg ) ; 
4040      resolve ( msg ) ; 
4141    } ) ; 
@@ -243,23 +243,6 @@ async function runBench(runFrameworks: FrameworkData[], benchmarkInfos: Benchmar
243243  } 
244244} 
245245
246- // FIXME: Clean up args. 
247- // What works: npm run bench keyed/react, npm run bench -- keyed/react, npm run bench -- keyed/react --count 1 --benchmark 01_ 
248- // What doesn't work (keyed/react becomes an element of argument benchmark): npm run bench -- --count 1 --benchmark 01_ keyed/react 
249- 
250- let  args : any  =  yargs ( process . argv ) 
251-   . usage ( 
252-     "$0 [--framework Framework1 Framework2 ...] [--benchmark Benchmark1 Benchmark2 ...] [--chromeBinary path] \n or: $0 [directory1] [directory2] .. [directory3]" 
253-   ) 
254-   . help ( "help" ) 
255-   . boolean ( "headless" ) . default ( "headless" ,  false ) 
256-   . boolean ( "smoketest" ) 
257-   . string ( "runner" ) . default ( "runner" , config . BENCHMARK_RUNNER ) 
258-   . string ( "browser" ) . default ( "browser" , config . BROWSER ) 
259-   . array ( "framework" ) 
260-   . array ( "benchmark" ) 
261-   . string ( "chromeBinary" ) . argv ; 
262- 
263246let  runner  =  args . runner ; 
264247if  ( [ BENCHMARK_RUNNER . WEBDRIVER_CDP , BENCHMARK_RUNNER . WEBDRIVER , BENCHMARK_RUNNER . WEBDRIVER_AFTERFRAME , 
265248  BENCHMARK_RUNNER . PLAYWRIGHT , 
@@ -305,7 +288,9 @@ async function main() {
305288    config . EXIT_ON_ERROR  =  true ; 
306289    console . log ( 'Using smoketest config ' ,  JSON . stringify ( config ) ) ; 
307290  } 
308-     
291+   if  ( config . BENCHMARK_RUNNER  ==  BENCHMARK_RUNNER . WEBDRIVER_AFTERFRAME )  { 
292+     config . RESULTS_DIRECTORY  =  "results_client_" + config . BROWSER ; 
293+   }     
309294  if  ( ! fs . existsSync ( config . RESULTS_DIRECTORY ) )  fs . mkdirSync ( config . RESULTS_DIRECTORY ) ; 
310295  if  ( ! fs . existsSync ( config . TRACES_DIRECTORY ) )  fs . mkdirSync ( config . TRACES_DIRECTORY ) ; 
311296
0 commit comments