Skip to content

Commit c5b794a

Browse files
authored
Merge pull request mozilla#687 from badboy/fix-benchmark
Bug 1727269 - Run the size benchmark against a full main checkout
2 parents 490433c + db7c56e commit c5b794a

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ jobs:
108108
- run:
109109
name: Get and post build sizes to GitHub PR
110110
command: |
111-
npm --prefix ./benchmarks install
112-
npm --prefix ./benchmarks run size:report
111+
./benchmarks/run.sh
113112
114113
check-qt-js:
115114
docker:

benchmarks/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Glean.js size benchmarks
2+
3+
Compare the size of the different Glean bundles across the local `main` branch and the current checkout.
4+
5+
## How to run
6+
7+
To run a local report:
8+
9+
```
10+
npm run size:report:dry
11+
```
12+
13+
To run the report and post the results to a GitHub pull request:
14+
15+
```
16+
npm run size:report
17+
```
18+
19+
_Note: This requires a `GITHUB_TOKEN` and the CircleCI environment to know which PR to post to._

benchmarks/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66
"type": "module",
77
"scripts": {
88
"link:glean": "cd ../glean && npm i && npm run build && npm link && cd ../benchmarks && npm link @mozilla/glean",
9-
"link:glean:main": "git stash && git checkout main && npm run link:glean && git checkout @{-1} && git stash apply",
109
"size:build:webext": "webpack --config ./size/webext/webpack.config.js",
1110
"size:build:webext:main": "npm run size:build:webext -- -o dist/size/webext/main",
1211
"size:build:qt": "mkdir -p ./dist/size/qt/ && cp ../glean/dist/qt/org/mozilla/Glean/glean.lib.js ./dist/size/qt/",
1312
"size:build:qt:main": "mkdir -p ./dist/size/qt/ && cp ../glean/dist/qt/org/mozilla/Glean/glean.lib.js ./dist/size/qt/glean.main.lib.js",
1413
"size:build": "run-s link:glean size:build:webext size:build:qt",
15-
"size:build:main": "run-s link:glean:main size:build:webext:main size:build:qt:main",
16-
"size:report:dry": "run-s size:build size:build:main && DRY_RUN=1 node --experimental-json-modules size/report.js",
17-
"size:report": "run-s size:build:main size:build && node --experimental-json-modules size/report.js"
14+
"size:build:main": "run-s link:glean size:build:webext:main size:build:qt:main",
15+
"size:report:dry": "DRY_RUN=1 ./run.sh",
16+
"size:report": "./run.sh"
1817
},
1918
"author": "The Glean Team <glean-team@mozilla.com>",
2019
"license": "MPL-2.0",

benchmarks/run.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
set -xe
4+
5+
WORKSPACE_ROOT="$( cd "$(dirname "$0")/.." ; pwd -P )"
6+
cd "$WORKSPACE_ROOT"
7+
8+
# Benchmark the main branch
9+
tmpdir=$(mktemp -d)
10+
git worktree add --force "${tmpdir}" main
11+
pushd "${tmpdir}"
12+
npm --prefix ./benchmarks install
13+
npm --prefix ./benchmarks run size:build:main
14+
cp -a "${tmpdir}/benchmarks/dist" "${WORKSPACE_ROOT}/benchmarks"
15+
popd
16+
git worktree remove --force "${tmpdir}"
17+
18+
# Benchmark the current code
19+
npm --prefix ./benchmarks install
20+
npm --prefix ./benchmarks run size:build
21+
22+
# Post the details
23+
node --experimental-json-modules benchmarks/size/report.js

0 commit comments

Comments
 (0)