Skip to content

Instantly share code, notes, and snippets.

@dirq
Created February 16, 2022 00:08
Show Gist options
  • Save dirq/d4e51852fc50e18f892b2b84f9d60cdf to your computer and use it in GitHub Desktop.
Save dirq/d4e51852fc50e18f892b2b84f9d60cdf to your computer and use it in GitHub Desktop.
Script to run Lighthouse CLI performance tests
# install nodejs
# run npm i -g lighthouse
# open powershell to folder where you saved this file
# use like:
# .testsite mycogen.com
Param (
$url
)
$timestamp = Get-Date -Format yyyymmdd-hhmmss
$filename = "$url" -replace 'http://|https://', '' -replace '[\W]{1,}', '_'
if (-not ($url -like 'http*')){
$url = "http://$url"
}
$filename += "-$timestamp.html"
$folder = 'C:/temp/'
$path = "$folder$filename"
Write-Output "Url: $url"
# see https://github.com/GoogleChrome/lighthouse#cli-options
# for the CLI options
# mac ppl can just run it without this powershell wrapper
lighthouse $url --output html --output-path $path --chrome-flags="--headless --disable-extensions" --emulated-form-factor desktop --throttling.rttMs 150 --throttling.throughputKbps 1638 --throttling.requestLatencyMs 562.5 --throttling.downloadThroughputKbps 1474 --throttling.uploadThroughputKbps 675 --throttling.cpuSlowdownMultiplier 4
Write-Output "-- DONE --"
Write-Output "Output: $path"
ii $folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment