seriesoftubes/.github/workflows/perf.yml
Frederic Jung c76dd4d556
Benchmark in real Chromium too, and only call a row slower when the samples say so
npm run perf -- --browser times the same workloads in Chromium as a desktop
and as a phone (390x844 at 3x, CPU slowed 4x), one browser per version. Each
run collects garbage first and ends by forcing layout and the map canvas, so
deferred work counts. The jsdom DOM is about 30x slower than a browser's and
has no layout, so the interface rows need this.

Shared machines swing single runs by 30% on identical code, CPU time
included. A row now counts as slower or faster only when it moved 15% and a
Mann-Whitney U test gives p < 0.01 (15 runs a side by default). Identical
code: no flags in three full runs; a routing slowdown planted in a copy is
flagged in jsdom and on the phone.

The panel workload renders both selections every run instead of alternating,
which split its samples in two. CI drives the runner's Chrome through
playwright-core, no browser download.
2026-10-26 12:04:57 +01:00

55 lines
1.9 KiB
YAML

name: Performance
# Times the PR against its base on a very large network, headless and in Chrome (desktop and a throttled phone),
# and uploads the tables. A separate workflow
# (perf-comment.yml) posts it on the PR: runs for pull requests from forks have no write access.
on:
pull_request:
paths:
- 'site/**'
- 'scripts/perf-*.js'
- 'tests/fixtures/**'
- 'tests/harness.js'
workflow_dispatch:
permissions:
contents: read
jobs:
bench:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
- run: npm ci
- name: Base version of the game
if: github.event_name == 'pull_request'
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
git fetch --depth=1 origin "$BASE_SHA"
git show FETCH_HEAD:site/index.html > "$RUNNER_TEMP/base.html"
echo "BASE_ARG=--base $RUNNER_TEMP/base.html" >> "$GITHUB_ENV"
- name: Benchmark
# The runner image ships Google Chrome; playwright-core (a dev dependency) drives it, no browser download.
run: |
export PERF_CHROME="$(command -v google-chrome || command -v google-chrome-stable || command -v chromium)"
echo "Chrome: $PERF_CHROME ($("$PERF_CHROME" --version))"
node scripts/perf-bench.js $BASE_ARG --browser --md perf.md --summary "$GITHUB_STEP_SUMMARY"
- name: Remember the PR number
if: github.event_name == 'pull_request'
env:
PR: ${{ github.event.pull_request.number }}
run: echo "$PR" > pr-number.txt
- uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: perf
path: |
perf.md
pr-number.txt
retention-days: 7