Repository navigation
Add performance benchmark - #35
Merged
Merged
Conversation
This was referenced Oct 20, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a reproducible performance benchmark for
@bloxwap/hapticunderpackages/haptic/bench/, run withnpm run benchfrom the repo root (about 11 seconds). It buildsdist, then measures:web-haptics.renderToStringwith 1, 100 and 1,000 targets.<Profiler>and an instrumented copy ofdist.triggerHaptic().No runtime or dev dependencies were added; it uses the existing esbuild, jsdom and React.
src/is unchanged.bench/is not in the npm tarball (pack:checkpasses), and results are written to the git-ignoredbench/results/latest.json. Counts are reported, not asserted, so later optimizations won't break the benchmark. Seepackages/haptic/bench/README.mdfor each metric and its caveats.Checks run locally and passing:
npm ci,npm run lint,npm run typecheck,npm run coverage(134 tests, 100%),npm run size(4,516 gzip bytes of an 8,192 budget),npm run pack:checkandnpm run test:matrix(React 18 and 19).Baseline results
The run was on
mainatbe63babwith the same benchmark code as this branch: Node v24.22.0, Linux 6.12, an Intel Xeon with 8 cores and 15.6 GiB RAM. jsdom timings are relative signals, not device latency. Synthetic clicks don't prove tactile output.What stands out
triggerHapticstill pulls in all 6,440 bytes ofweb-haptics, for 3,313 gzip bytes in total. Only the preset table is used, but it shares a chunk with theWebHapticsclass.WebHapticsengine. That engine adds a hidden label and switch to<body>and runs an rAF loop: 100 distinct taps made 100 engines and 300 body nodes.HapticTargetrenders 3 times per mount, versus 1 on the vibration path. Mounting 1,000 took about 108–141 ms, versus about 38 ms.Follow-up optimization issues are linked from this PR.