(benchmark, headless)
| 105 | } |
| 106 | |
| 107 | async function runBenchmark(benchmark, headless) { |
| 108 | const results = { |
| 109 | runs: [], |
| 110 | averages: [], |
| 111 | }; |
| 112 | |
| 113 | await initChrome(); |
| 114 | |
| 115 | for (let i = 0; i < timesToRun; i++) { |
| 116 | let chrome = await launchChrome(headless); |
| 117 | |
| 118 | results.runs.push(await runScenario(benchmark, chrome)); |
| 119 | // add a delay or sometimes it confuses lighthouse and it hangs |
| 120 | await wait(500); |
| 121 | try { |
| 122 | await chrome.kill(); |
| 123 | } catch (e) {} |
| 124 | } |
| 125 | |
| 126 | results.averages = calculateAverages(results.runs); |
| 127 | return results; |
| 128 | } |
| 129 | |
| 130 | module.exports = runBenchmark; |
no test coverage detected