5.0.2 • Published 2 years ago

webperf-comparison v5.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Web performance comparison tool

Purpose

Pre-requisites

  • Node 14+, I haven't tested on any previous versions, so ultimately it could work prior, but I haven't validated it. YMMV
  • Chrome installed -- Necessary for running lighthouse!

Target audience

Developers - I didn't implement any error logging because there aren't many recoverable steps. If errors arise, I feel the errors in the dependencies themselves provide enough context as to what went wrong. Hence, my target audience is one who can read & understand unhandled promise rejections.

Starting

by way of cloning this project

  • Install the packages, using npm i
  • Start the prompts using npm start

via the published module

  • Run the command npx webperf-comparison
  1. Answer all the prompts (note: light gray values represent defaults, pressing enter accepts the default, and any keystroke erases the default)
  2. Let lighthouse do its magic, the progress bar should keep you up to date on status
  3. See the output table

Previous Use

If you want to re-evaluate the previous run, which leverages the results.json written to disk, you can use the command: webperf-comparison --usePrevious or, if cloned, npm run start:previous

Want to run your own Chromium? Use the CHROME_PATH environment argument

chrome-launcher allows you to define the CHROME_PATH for the launcher. For instance, if you wanted to run Brave Browser, you could do CHROME_PATH="C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe" npm start, and huzzah, it works!

Implementation

Using prompts, we gather the URL of the host(s) to run against. Additionally, we ask a series of path segments to test against for each experience and how many times to run the test. Many of these values can be set by a .webperfrc for convenience.

.webperfrc

The configuration file can be defined in a number of ways, as per the rc module documentation. The simplest way is to provide the file by way of --config=.webperfrc.

PropertyDescription
runsThe number of times to run lighthouse against each URL/route combination
hostsA comma delimited list of hosts to test against
routesA comma delimited list of paths to test per URL (i.e. /, /test)
loadSiteWhether to load the results details site upon finish, leaving just the command line output
chromePathPath to Chromium install, optional
networkNetwork throttling option, see Network throttling
cpuCPU throttling option, see CPU throttling

Network throttling (case insensitive)

Lighthouse allows network throttling to be simulated. I had looked at throttle to enable this at the hardware level, but it would require sudo permissions and only works on Mac/Linux. Instead, I opted for simulated network throttling which is built into lighthouse itself.

OptionRound trip time (ms)Upload speed (Kbps)Download speed (Kbps)
3gslow200400400
3g1507681600
3gfast757681600
4g8590009000
cable1410005000

CPU throttling (case insensitive)

Additional to network throttling, Lighthouse allows CPU throttling which helps mimic processing capabilities of mobile phones vs the device running this module. This is important for testing things like LCP/FID/Blocking time, etc.

OptionCPU modifier, 1/modifierDescription
slow_mobile6Slow mobile
mobile4Mobile
desktop1Your device

Site development

Want to help change what the site output is? That's great! Thanks for the help, in advance. You will have to clone this repository to do so. After installing the npm modules, you should be able to invoke npm start:site to get running locally.

Note, it does require a valid results.json file at the root of the project directory, so you'll have to drop one in or produce one via npm start.