@ntcore-ts/react 1.0.0 → 1.0.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -36,6 +36,34 @@ function Dashboard() {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
+
A single `useTopic` update is about **88k/s** (~11 µs). A 50-hook dashboard updating in one React batch is about **4.5k** full refreshes/s (~240 µs). That is far above typical FRC NT rates.
|
|
40
|
+
|
|
41
|
+
```mermaid
|
|
42
|
+
xychart-beta
|
|
43
|
+
title "React updates per second (jsdom, Apple M1 Pro)"
|
|
44
|
+
x-axis ["useTopic", "usePrefixTopic", "50 hooks batched"]
|
|
45
|
+
y-axis "updates/s" 0 --> 90000
|
|
46
|
+
bar [88000, 85000, 4500]
|
|
47
|
+
```
|
|
48
|
+
|
|
39
49
|
## Running unit tests
|
|
40
50
|
|
|
41
51
|
Run `npm run test -w @ntcore-ts/react` to execute the unit tests via [Vitest](https://vitest.dev/).
|
|
52
|
+
|
|
53
|
+
## Benchmarks
|
|
54
|
+
|
|
55
|
+
Hook update benches measure `useTopic` / `usePrefixTopic` from callback to a jsdom DOM commit. They are **not** run in the default test suite.
|
|
56
|
+
|
|
57
|
+
- From the repo root: `npm run bench` (client and React)
|
|
58
|
+
- From this package: `npm run bench -w @ntcore-ts/react`
|
|
59
|
+
|
|
60
|
+
On an Apple M1 Pro (jsdom):
|
|
61
|
+
|
|
62
|
+
| Workload | Rate | Mean |
|
|
63
|
+
| ----------------------------- | -----: | -----: |
|
|
64
|
+
| `useTopic` (one update) | 88k/s | 11 µs |
|
|
65
|
+
| `usePrefixTopic` (one update) | 85k/s | 12 µs |
|
|
66
|
+
| 50 hooks, one batched update | 4.5k/s | 240 µs |
|
|
67
|
+
| 50 hooks, unbatched | 800/s | 1.3 ms |
|
|
68
|
+
|
|
69
|
+
CI re-runs these benches on every PR and fails if throughput drops to half of `main`. See the [performance guide](https://ntcore.chrislawson.dev/guide/performance).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ntcore-ts/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-beta.1",
|
|
4
4
|
"description": "React bindings for @ntcore-ts/client (NetworkTables for FRC)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"typecheck": "tsc -p tsconfig.spec.json --noEmit",
|
|
25
25
|
"build": "rm -rf dist && rollup -c rollup.config.mts",
|
|
26
26
|
"test": "vitest run",
|
|
27
|
-
"
|
|
27
|
+
"bench": "vitest bench --run",
|
|
28
|
+
"lint": "oxlint ."
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
31
|
"react": ">=18.0.0",
|