Created
February 16, 2022 00:08
-
-
Save dirq/d4e51852fc50e18f892b2b84f9d60cdf to your computer and use it in GitHub Desktop.
Script to run Lighthouse CLI performance tests
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
# 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