Last active
May 31, 2022 16:15
-
-
Save kadiks/a7fee09f18ab38636a1728f6b5c35ef0 to your computer and use it in GitHub Desktop.
CLI lighthouse comparison between React & Vue doc websites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lighthouse = require("lighthouse"); | |
const chromeLauncher = require("chrome-launcher"); | |
const runReport = async (url) => { | |
const chrome = await chromeLauncher.launch({ | |
chromeFlags: ["--headless"], | |
}); | |
const options = { output: "json", port: chrome.port }; | |
const runnerResult = await lighthouse(url, options); | |
await chrome.kill(); | |
const { audits } = runnerResult.lhr; | |
console.log( | |
audits.interactive.displayValue, | |
"|", | |
audits["total-blocking-time"].displayValue | |
); | |
}; | |
const runReports = async (url, runs) => { | |
const arr = [...Array(runs)]; | |
for (const index of arr) { | |
await runReport(url); | |
} | |
}; | |
const start = async (urls, runs = 10) => { | |
for (const url of urls) { | |
console.log(url, `(${runs} runs)`); | |
console.log("TTI", "|", "TBT"); | |
await runReports(url, runs); | |
} | |
}; | |
start(["https://beta.reactjs.org", "https://vuejs.org"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment