MCPcopy Create free account
hub / github.com/facebook/memlab / warmup

Function warmup

packages/api/src/API.ts:345–384  ·  view source on GitHub ↗
(options: APIOptions = {})

Source from the content-addressed store, hash-verified

343 * @param options configure browser interaction run
344 */
345export async function warmup(options: APIOptions = {}): Promise<void> {
346 const config = options.config ?? defaultConfig;
347 if (config.verbose) {
348 info.lowLevel(`Xvfb: ${config.useXVFB}`);
349 }
350 const testPlanner = options.testPlanner ?? defaultTestPlanner;
351 try {
352 if (config.skipWarmup) {
353 return;
354 }
355 const browser = await APIUtils.getBrowser({warmup: true});
356
357 const visitPlan = testPlanner.getVisitPlan();
358 config.setDevice(visitPlan.device);
359
360 const numOfWarmup = visitPlan.numOfWarmup || 3;
361 const promises = [];
362 for (let i = 0; i < numOfWarmup; ++i) {
363 promises.push(browser.newPage());
364 }
365 const pages = await Promise.all(promises);
366 info.beginSection('warmup');
367 await Promise.all(
368 pages.map(async page => {
369 await setupPage(page, {cache: false});
370 const interactionManager = new E2EInteractionManager(page, browser);
371 await interactionManager.warmupInPage();
372 }),
373 ).catch(err => {
374 info.error(err.message);
375 });
376 info.endSection('warmup');
377
378 await utils.closePuppeteer(browser, pages, {warmup: true});
379 } catch (ex) {
380 const error = utils.getError(ex);
381 utils.checkUninstalledLibrary(error);
382 throw ex;
383 }
384}
385
386function getConfigFromRunOptions(options: RunOptions): MemLabConfig {
387 let config = MemLabConfig.getInstance();

Callers 3

runMethod · 0.90
warmupAndTakeSnapshotsFunction · 0.85
runFunction · 0.85

Calls 8

warmupInPageMethod · 0.95
setupPageFunction · 0.85
lowLevelMethod · 0.80
getVisitPlanMethod · 0.80
setDeviceMethod · 0.80
beginSectionMethod · 0.80
errorMethod · 0.80
endSectionMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…