Created
September 29, 2020 13:42
-
-
Save svkrclg/e9a758ecf43d3db583439c897f566d64 to your computer and use it in GitHub Desktop.
Lighthouse Unthrottle run
This file contains 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
/*Need to change fetch different value from url array manually. | |
Because performance degrades with continous run. | |
*/ | |
const fs = require('fs'); | |
const lighthouse = require('lighthouse'); | |
const chromeLauncher = require('chrome-launcher'); | |
const url = ["https://www.amazon.in/", "https://twitter.com/", "https://www.snapdeal.com/", "https://abc.com/", "https://www.ticket.at/de/home" ]; | |
(async () => { | |
element = url[1] | |
const chrome = await chromeLauncher.launch(); | |
const options = {logLevel: 'silent', output: 'json', onlyCategories: ['performance'], port: chrome.port}; | |
const config = { | |
extends: 'lighthouse:default', | |
settings: { | |
maxWaitForFcp: 15 * 1000, | |
maxWaitForLoad: 35 * 1000, | |
emulatedFormFactor: 'desktop', | |
throttling: { | |
rttMs: 40, | |
throughputKbps: 10 * 1024, | |
requestLatencyMs: 0, | |
downloadThroughputKbps: 0, | |
uploadThroughputKbps: 0, | |
} | |
} | |
}; | |
const runnerResult = await lighthouse(element, options, config); | |
// `.report` is the HTML report as a string | |
const report = runnerResult.report; | |
const file_name = element.split('/')[2]+".json" | |
fs.writeFileSync(file_name, report); | |
console.log("URL: "+element+ ", " +runnerResult.lhr.categories.performance.score * 100, "runtime: "+ JSON.parse(report).timing.total); | |
await chrome.kill(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment