1
1
import { fork } from "child_process" ;
2
2
import * as fs from "fs" ;
3
3
import * as yargs from "yargs" ;
4
- import { BenchmarkInfo , BenchmarkType } from "./benchmarksGeneric " ;
5
- import { BenchmarkPuppeteer , benchmarksPuppeteer } from "./benchmarksPuppeteer" ;
6
- import { benchmarksWebdriver , BenchmarkWebdriver , LighthouseData } from "./benchmarksWebdriver" ;
4
+ import { BenchmarkInfo , BenchmarkType } from "./benchmarksCommon " ;
5
+ import { BenchmarkPuppeteer } from "./benchmarksPuppeteer" ;
6
+ import { BenchmarkWebdriver , LighthouseData } from "./benchmarksWebdriver" ;
7
7
import { BenchmarkOptions , config , ErrorAndWarning , FrameworkData , initializeFrameworks } from "./common" ;
8
8
import { writeResults } from "./writeResults" ;
9
+ import { benchmarks } from "./benchmarkConfiguration" ;
9
10
10
11
function forkAndCallBenchmark (
11
12
framework : FrameworkData ,
12
13
benchmark : BenchmarkInfo ,
13
14
benchmarkOptions : BenchmarkOptions
14
15
) : Promise < ErrorAndWarning > {
15
16
return new Promise ( ( resolve , reject ) => {
16
- const forked = fork (
17
- benchmark . type == BenchmarkType . MEM ? "dist/forkedBenchmarkRunnerPuppeteer.js" : "dist/forkedBenchmarkRunnerWebdriver.js"
18
- ) ;
17
+ let forkedRunner = null ;
18
+ if ( benchmarks . some ( b => b . benchmarkInfo . id == benchmark . id && b instanceof BenchmarkPuppeteer ) ) {
19
+ forkedRunner = "dist/forkedBenchmarkRunnerPuppeteer.js" ;
20
+ } else {
21
+ forkedRunner = "dist/forkedBenchmarkRunnerWebdriver.js" ;
22
+ }
23
+ console . log ( "forking " , forkedRunner ) ;
24
+ const forked = fork ( forkedRunner ) ;
19
25
if ( config . LOG_DETAILS ) console . log ( "FORKING: forked child process" ) ;
20
26
forked . send ( {
21
27
config,
@@ -87,7 +93,7 @@ async function runBenchmakLoop(
87
93
}
88
94
}
89
95
if ( benchmark . type == BenchmarkType . CPU ) {
90
- // console.log("CPU results before: ", results);
96
+ console . log ( "CPU results before: " , results ) ;
91
97
( results as number [ ] ) . sort ( ( a : number , b : number ) => a - b ) ;
92
98
results = results . slice ( 0 , config . NUM_ITERATIONS_FOR_BENCHMARK_CPU ) ;
93
99
// console.log("CPU results after: ", results)
@@ -109,13 +115,9 @@ async function runBench(runFrameworks: FrameworkData[], benchmarkNames: string[]
109
115
let errors : String [ ] = [ ] ;
110
116
let warnings : String [ ] = [ ] ;
111
117
112
- let b1 : Array < BenchmarkWebdriver | BenchmarkPuppeteer > = benchmarksWebdriver . filter ( ( b ) =>
118
+ let runBenchmarks : Array < BenchmarkWebdriver | BenchmarkPuppeteer > = benchmarks . filter ( ( b ) =>
113
119
benchmarkNames . some ( ( name ) => b . id . toLowerCase ( ) . indexOf ( name ) > - 1 )
114
120
) ;
115
- let b2 : Array < BenchmarkWebdriver | BenchmarkPuppeteer > = benchmarksPuppeteer . filter ( ( b ) =>
116
- benchmarkNames . some ( ( name ) => b . id . toLowerCase ( ) . indexOf ( name ) > - 1 )
117
- ) ;
118
- let runBenchmarks : Array < BenchmarkWebdriver | BenchmarkPuppeteer > = b1 . concat ( b2 ) ;
119
121
120
122
let restart : string = undefined ;
121
123
let index = runFrameworks . findIndex ( ( f ) => f . fullNameWithKeyedAndVersion === restart ) ;
@@ -132,6 +134,8 @@ async function runBench(runFrameworks: FrameworkData[], benchmarkNames: string[]
132
134
runBenchmarks . map ( ( b ) => b . id )
133
135
) ;
134
136
137
+ console . log ( "HEADLESS*** " , args . headless ) ;
138
+
135
139
let benchmarkOptions : BenchmarkOptions = {
136
140
port : config . PORT . toFixed ( ) ,
137
141
remoteDebuggingPort : config . REMOTE_DEBUGGING_PORT ,
@@ -188,7 +192,7 @@ let args: any = yargs(process.argv)
188
192
"$0 [--framework Framework1 Framework2 ...] [--benchmark Benchmark1 Benchmark2 ...] [--chromeBinary path] \n or: $0 [directory1] [directory2] .. [directory3]"
189
193
)
190
194
. help ( "help" )
191
- . boolean ( "headless" )
195
+ . boolean ( "headless" ) . default ( "headless" , false )
192
196
. boolean ( "smoketest" )
193
197
. array ( "framework" )
194
198
. array ( "benchmark" )
@@ -218,6 +222,7 @@ async function main() {
218
222
}
219
223
220
224
if ( ! fs . existsSync ( config . RESULTS_DIRECTORY ) ) fs . mkdirSync ( config . RESULTS_DIRECTORY ) ;
225
+ if ( ! fs . existsSync ( config . TRACES_DIRECTORY ) ) fs . mkdirSync ( config . TRACES_DIRECTORY ) ;
221
226
222
227
if ( args . help ) {
223
228
yargs . showHelp ( ) ;
0 commit comments