Part II β The Shield Β· Lesson 4.5
Performance Testing
In one lineTurn performance into a build gate with numbers, so regressions fail CI instead of shipping.
Where you've seen itA pull request that imports one convenience library, adds 180KB to the main bundle, and gets blocked before a human reads it.
Diagram
How it works
- Set budgets from current p75, slightly tighter β a budget nobody can pass gets disabled within a week.
- Run Lighthouse CI on a fixed device profile and throttled network so numbers are comparable commit to commit.
- Add a bundle-size check (
size-limit,bundlesize) β it's faster, deterministic, and catches most regressions. - Run three passes and take the median; single Lighthouse runs vary by 10β20%.
- Load-test the API separately (k6, Artillery) β a frontend that's fast at 10 users and dead at 10,000 is still broken.
Trade-offs
| Check | Speed | Catches |
|---|---|---|
| Bundle size limit | seconds | dependency bloat, bad imports |
| Lighthouse CI | ~1 min | render-blocking, unused JS, CLS |
| WebPageTest | minutes | real device, filmstrip, waterfall |
| RUM (field) | continuous | what users actually experience |
Interview angle
"How do you stop performance regressing over time?"
- Make it a gate, not a goal: budgets fail CI so no regression merges silently.
- Cheap deterministic checks (bundle size) on every PR, full Lighthouse on main, RUM alerting in production.
- Track p75 on real devices β averages hide exactly the users who churn.
Recap
- Budgets in CI beat performance sprints, because they prevent instead of repair.
- Lab numbers gate merges; field numbers tell you the truth.
- Median of three runs, p75 of real users.