Skip to content

Commit 081e48d

Browse files
committed
No seeding
1 parent e432527 commit 081e48d

File tree

9 files changed

+292
-162
lines changed

9 files changed

+292
-162
lines changed

examples/benchmark-react/README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The repo has two benchmark suites:
1414
- **What we measure:** Wall-clock time from triggering an action (e.g. `mount(100)` or `updateAuthor('author-0')`) until the harness sets `data-bench-complete` (after two `requestAnimationFrame` callbacks). Optionally we also record React Profiler commit duration and, with `BENCH_TRACE=true`, Chrome trace duration.
1515
- **Why:** Normalized caching should show wins on shared-entity updates (one store write, many components update), ref stability (fewer new object references), and derived-view memoization (`Query` schema avoids re-sorting when entities haven't changed). See [js-framework-benchmark "How the duration is measured"](https://github.com/krausest/js-framework-benchmark/wiki/How-the-duration-is-measured) for a similar timeline-based approach.
1616
- **Statistical:** Warmup runs are discarded; we report median and 95% CI. Libraries are interleaved per round to reduce environmental variance.
17-
- **No CPU throttling:** Runs at native speed with more samples (3 warmup + 30 measurement locally, 15 in CI) for statistical significance rather than artificial slowdown.
17+
- **No CPU throttling:** Runs at native speed with more samples for statistical significance rather than artificial slowdown. Small (cheap) scenarios use 3 warmup + 15 measurement runs locally (10 in CI); large (expensive) scenarios use 1 warmup + 4 measurement runs.
1818

1919
## Scenario categories
2020

@@ -133,6 +133,44 @@ Regressions >5% on stable scenarios or >15% on volatile scenarios are worth inve
133133
- `BENCH_PORT=<port>` — port for `preview` server and bench runner (default `5173`)
134134
- `BENCH_BASE_URL=<url>` — full base URL override (takes precedence over `BENCH_PORT`)
135135

136+
4. **Filtering scenarios**
137+
138+
The runner supports CLI flags (with env var fallbacks) to select a subset of scenarios:
139+
140+
| CLI flag | Env var | Description |
141+
|---|---|---|
142+
| `--lib <names>` | `BENCH_LIB` | Comma-separated library names (e.g. `data-client,swr`) |
143+
| `--size <small\|large>` | `BENCH_SIZE` | Run only `small` (cheap, full rigor) or `large` (expensive, reduced runs) scenarios |
144+
| `--action <group\|action>` | `BENCH_ACTION` | Filter by action group (`mount`, `update`, `mutation`, `memory`) or exact action name |
145+
| `--scenario <pattern>` | `BENCH_SCENARIO` | Substring filter on scenario name |
146+
147+
CLI flags take precedence over env vars. Examples:
148+
149+
```bash
150+
yarn bench --lib data-client # only data-client
151+
yarn bench --size small # only cheap scenarios (full warmup/measurement)
152+
yarn bench --action mount # mount, mountSortedView, bulkIngest
153+
yarn bench --action update --lib swr # update scenarios for swr only
154+
yarn bench --scenario sorted-view # only sorted-view scenarios
155+
```
156+
157+
Convenience scripts:
158+
159+
```bash
160+
yarn bench:small # --size small
161+
yarn bench:large # --size large
162+
yarn bench:dc # --lib data-client
163+
```
164+
165+
5. **Scenario sizes**
166+
167+
Scenarios are classified as `small` or `large` based on their cost:
168+
169+
- **Small** (3 warmup + 15 measurement): `mount-100-items`, `update-single-entity`, `update-shared-author-duration`, `ref-stability-*`, `optimistic-update`, `invalidate-and-resolve`, `create-item`, `delete-item`
170+
- **Large** (1 warmup + 4 measurement): `mount-500-items`, `update-shared-author-500-mounted`, `update-shared-author-2000-mounted`, `memory-mount-unmount-cycle`, `update-shared-author-with-network`, `bulk-ingest-500`, `sorted-view-mount-500`, `sorted-view-update-entity`
171+
172+
When running all scenarios (`yarn bench`), each group runs with its own warmup/measurement count. Use `--size` to run only one group.
173+
136174
## Output
137175

138176
The runner prints a JSON array in `customSmallerIsBetter` format (name, unit, value, range) to stdout. In CI this is written to `react-bench-output.json` and sent to the benchmark action.

0 commit comments

Comments
 (0)