Skip to content

Commit d2f207a

Browse files
committed
docs: better readme
1 parent ed6e308 commit d2f207a

File tree

2 files changed

+64
-29
lines changed

2 files changed

+64
-29
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88
### Fixed
99
- docs: add CHANGELOG
10+
- docs: better README
1011

1112
## [1.0.0] - 2020-01-27
1213
### Added

README.md

Lines changed: 63 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@ Google PageSpeed score command line toolkit
77

88
Get a score and metrics via the Google PageSpeed Insights API or a local Lighthouse run.
99

10-
- [Recommendations for using the score and metrics values](#recommendations-for-using-the-score-and-metrics-values)
10+
> For recommendations about using the score check out my blog post: [What's in the Google PageSpeed score?](https://medium.com/expedia-group-tech/whats-in-the-google-pagespeed-score-a5fc93f91e91)
11+
1112
- [Requirements](#requirements)
1213
- [Usage](#usage)
13-
- [`--strategy` - mobile or desktop](#--strategy---mobile-or-desktop)
14-
- [`--runs` - multiple runs](#--runs---multiple-runs)
15-
- [`--local` - local mode](#--local---local-mode)
16-
- [`LANTERN_DEBUG=true` - save metrics estimation traces](#lantern_debugtrue---save-metrics-estimation-traces)
17-
18-
## Recommendations for using the score and metrics values
19-
20-
Check out my blog post for more details: [What's in the Google PageSpeed score?](https://medium.com/expedia-group-tech/whats-in-the-google-pagespeed-score-a5fc93f91e91)
14+
- [multiple runs](#multiple-runs)
15+
- [mobile or desktop strategy](#mobile-or-desktop-strategy)
16+
- [save result JSON to disk](#save-result-json-to-disk)
17+
- [Local mode](#local-mode)
18+
- [set CPU slowdown multiplier](#set-cpu-slowdown-multiplier)
19+
- [save trace & devtools log to disk](#save-trace--devtools-log-to-disk)
20+
- [save Lantern metrics estimation traces](#save-lantern-metrics-estimation-traces)
2121

2222
## Requirements
2323

24-
The pagespeed score CLI requires **node.js 10+** (because it relies on async iterators).
24+
* **node.js 10+** - because of [`for-await...of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of)
25+
* (**Google Chrome**) - in case you want to run [local mode](#local-mode)
2526

2627
## Usage
2728

@@ -37,53 +38,87 @@ FCP, FMP, SI, FCI, TTI are the values (in seconds) for the 5 metrics that affect
3738

3839
Use `--help` see the list of all options.
3940

40-
### `--strategy` - mobile or desktop
41+
### multiple runs
42+
43+
`--runs <N>` overrides the number of runs (default: 1). For more than 1 runs stats will be calculated.
44+
45+
```
46+
$ npx pagespeed-score --runs 3 https://www.google.com
47+
name score FCP FMP SI FCI TTI
48+
run 1 96 0.9 1.0 1.2 3.1 3.9
49+
run 2 96 0.9 1.0 1.0 3.1 3.7
50+
run 3 95 0.9 1.0 1.2 3.5 4.0
51+
52+
median 96 0.9 1.0 1.2 3.1 3.9
53+
stddev 0.6 0.0 0.0 0.1 0.2 0.2
54+
min 95 0.9 1.0 1.0 3.1 3.7
55+
max 96 0.9 1.0 1.2 3.5 4.0
56+
```
57+
58+
### mobile or desktop strategy
4159

42-
`--strategy <mobile|desktop>` sets the lighthouse strategy (default: mobile)
60+
`--strategy <mobile|desktop>` sets the Lighthouse strategy (default: mobile)
4361

4462
```
4563
$ npx pagespeed-score --strategy desktop https://www.google.com
4664
name score FCP FMP SI FCI TTI
4765
run 1 100 0.5 0.5 0.5 0.9 0.9
4866
```
4967

50-
### `--runs` - multiple runs
68+
### save result JSON to disk
5169

52-
`--runs <N>` overrides the number of runs (default: 1). For more than 1 runs stats will be calculated.
70+
`--save-results` will save all Lighthouse results (from the PSI API response or local Lighthouse run) as JSON files.
5371

5472
```
55-
$ npx pagespeed-score --runs 3 https://www.google.com
73+
$ npx pagespeed-score --save-results --runs=2 https://www.google.com
5674
name score FCP FMP SI FCI TTI
5775
run 1 96 0.9 1.0 1.2 3.1 3.9
5876
run 2 96 0.9 1.0 1.0 3.1 3.7
59-
run 3 95 0.9 1.0 1.2 3.5 4.0
6077
61-
median 96 0.9 1.0 1.2 3.1 3.9
62-
stddev 0.6 0.0 0.0 0.1 0.2 0.2
63-
min 95 0.9 1.0 1.0 3.1 3.7
64-
max 96 0.9 1.0 1.2 3.5 4.0
78+
$ ls
79+
1-0.result.json
80+
2-0.result.json
6581
```
6682

67-
### `--local` - local mode
83+
## Local mode
6884

6985
Switches to running Lighthouse locally instead of calling the PSI API. This can be useful for non-public URLs (e.g. staging environment on a private network) or debugging. To ensure the local results are close to the PSI API results this module:
7086

71-
* uses the same version of LightHouse as PSI (5.0.0 as of 26 June 2019)
72-
* uses the [LightRider mobile config](https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/config/lr-mobile-config.js)
73-
* allows throttling of CPU with `--cpu-slowdown` (default 4x). Please note that PSI infrastructure already runs on a slower CPU (that's like a mobile device) hence the need to slow our laptops CPU down for local runs.
74-
* you can also use the same Chrome version as PSI (76 as of 21 June 2019) by specifying CHROME_PATH
87+
* uses the same version of LightHouse as PSI (5.6.0 as of 2020-01-27)
88+
* uses the [LightRider mobile config](https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/config/lr-mobile-config.js) like PSI
89+
* allows throttling of CPU to better match PSI infrastructure limits
90+
* you can also use the same Chrome version as PSI (78 as of 2020-01-27) by specifying CHROME_PATH (and ensuring you have the correct version installed)
7591

7692
```sh
77-
CHROME_PATH="/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" \
93+
CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
7894
npx pagespeed-score --local "<url>"
7995
```
8096

8197
Local results will still differ from the PSI API because of local hardware and network variability.
8298

99+
### set CPU slowdown multiplier
100+
101+
`--cpu-slowdown` will allow setting CPU throttling multiplier (default 4x). Only available in [local mode](#local-mode).
102+
103+
Please note that PSI infrastructure already runs on a slower CPU (that's like a mobile device) hence the need to slow our machines CPU down for local runs.
104+
105+
### save trace & devtools log to disk
106+
107+
`--save-assets` will save trace & devtools log to disk. Only available in [local mode](#local-mode).
108+
109+
```
110+
$ npx pagespeed-score --save-assets --local https://www.google.com
111+
name score FCP FMP SI FCI TTI
112+
run 1 95 1.4 1.4 1.7 3.6 3.8
113+
114+
$ ls
115+
1-0.devtoolslog.json
116+
1-0.trace.json
117+
```
83118

84-
### `LANTERN_DEBUG=true` - save metrics estimation traces
119+
### save Lantern metrics estimation traces
85120

86-
Setting `LANTERN_DEBUG=true` along with `--save-assets --local` will save traces for how metrics were simulated by Lantern.
121+
Setting the `LANTERN_DEBUG=true` environment variable along with `--save-assets --local` will save traces for how metrics were simulated by Lantern.
87122

88123
```
89124
$ LANTERN_DEBUG=true npx pagespeed-score \
@@ -93,7 +128,6 @@ run 1 95 1.4 1.4 1.7 3.6 3.8
93128
94129
$ ls
95130
1-0.devtoolslog.json
96-
1-0.report.json
97131
1-0.trace.json
98132
1-optimisticFirstContentfulPaint.trace.json
99133
1-optimisticFirstMeaningfulPaint.trace.json

0 commit comments

Comments
 (0)