()
| 175 | } |
| 176 | |
| 177 | async function main() { |
| 178 | logProgress('Preparing benchmark bundle') |
| 179 | await rm(cacheDir, { recursive: true, force: true }) |
| 180 | await mkdir(resultsDir, { recursive: true }) |
| 181 | await ensureFixtureBundle() |
| 182 | logProgress('Launching headless Chrome') |
| 183 | |
| 184 | const launchOptions = { |
| 185 | headless: true, |
| 186 | args: [ |
| 187 | '--enable-precise-memory-info', |
| 188 | '--js-flags=--expose-gc', |
| 189 | // Reduce OS/browser noise |
| 190 | '--disable-background-networking', |
| 191 | '--disable-background-timer-throttling', |
| 192 | '--disable-backgrounding-occluded-windows', |
| 193 | '--disable-renderer-backgrounding', |
| 194 | '--disable-ipc-flooding-protection', |
| 195 | '--disable-hang-monitor', |
| 196 | '--disable-extensions', |
| 197 | '--no-sandbox', |
| 198 | ], |
| 199 | } |
| 200 | if (executablePath) { |
| 201 | launchOptions.executablePath = executablePath |
| 202 | } |
| 203 | |
| 204 | const browser = await chromium.launch(launchOptions) |
| 205 | |
| 206 | try { |
| 207 | const fixtureBundleContent = await readFile(fixtureBundlePath, 'utf8') |
| 208 | |
| 209 | async function createBenchmarkPage() { |
| 210 | const page = await browser.newPage() |
| 211 | page.on('console', (message) => { |
| 212 | const text = message.text() |
| 213 | if (text.includes('Download the React DevTools')) { |
| 214 | return |
| 215 | } |
| 216 | console.log(`[page:${message.type()}] ${text}`) |
| 217 | }) |
| 218 | page.on('pageerror', (error) => { |
| 219 | console.error(`[pageerror] ${error.message}`) |
| 220 | }) |
| 221 | |
| 222 | await page.goto(pathToFileURL(cacheHtmlPath).toString(), { |
| 223 | waitUntil: 'networkidle', |
| 224 | }) |
| 225 | await page.addScriptTag({ content: fixtureBundleContent }) |
| 226 | await page.waitForFunction(() => Boolean(window.__reactTooltipBenchmark), null, { |
| 227 | timeout: timeoutMs, |
| 228 | }) |
| 229 | return page |
| 230 | } |
| 231 | |
| 232 | logProgress(`Running scaling benchmark for counts: ${counts.join(', ')}`) |
| 233 | |
| 234 | const runVersion = async (version) => { |
no test coverage detected