Skip to content

docs: add FAQ.md (measurement precision, JIT deopt, cross-tool differences)#609

Merged
jerome-benoit merged 7 commits into
tinylibs:mainfrom
deeferentleeg:docs/issue-190-faq
Jul 22, 2026
Merged

docs: add FAQ.md (measurement precision, JIT deopt, cross-tool differences)#609
jerome-benoit merged 7 commits into
tinylibs:mainfrom
deeferentleeg:docs/issue-190-faq

Conversation

@deeferentleeg

Copy link
Copy Markdown
Contributor

Summary

Closes #190 — adds a FAQ.md at the repo root covering the three topics in the issue's checklist:

  1. How to deal with measurement precision issues — timer resolution varies by runtime; use the timestampProvider shorthands (hrtimeNow/performanceNow/bunNanoseconds/auto), increase time, and watch the rme.
  2. What is JS JIT de-optimization — what deopt is, common causes during benchmarking (type instability, GC, DevTools), and how Tinybench's statistics surface it.
  3. Why results differ from another benchmarking tool — different timing APIs, methodology, statistics, warmup handling, and overhead; focus on relative rather than absolute numbers.

The content is grounded in the README's existing documentation of timestampProvider and the time option, and the issue author (@jerome-benoit) explicitly invited a PR for this in #143.

AI usage

An AI assistant was used to help locate the relevant code and draft this change. I have reviewed and understand every line of the diff, and I am the sole author of this contribution.

Closes #190

…-tool result differences

Adds a FAQ.md at the repo root addressing the three topics called out in
issue tinylibs#190 (measurement precision, JS JIT de-optimization, and why results
differ from other benchmarking tools), grounded in the README's existing
timestampProvider/time documentation.

Closes tinylibs#190

@jerome-benoit jerome-benoit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on — the structure maps cleanly to the three checklist items in #190 and the writing is concise.

Two claims contradict tinybench's actual behavior (warmup handling; GC listed as a deopt cause) and should be corrected before this lands, plus a few precision fixes noted inline.

Not blocking, repo-level: FAQ.md isn't linked from anywhere, so it's effectively undiscoverable. Please add ### [FAQ](./FAQ.md) under the README Docs section.

Comment thread FAQ.md Outdated
Comment thread FAQ.md Outdated
Comment thread FAQ.md Outdated
Comment thread FAQ.md Outdated
Comment thread FAQ.md Outdated
Comment thread FAQ.md Outdated
Comment thread FAQ.md Outdated
@pkg-pr-new

pkg-pr-new Bot commented Jul 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/tinybench@609

commit: 605065b

- Warmup: Tinybench warms up by default in a separate phase excluded from the
  reported statistics (cross-tool bullet + variance guidance corrected).
- Deopt: falls back to a lower execution tier (not necessarily the interpreter);
  GC pauses are a separate latency source, not a deopt cause; soften DevTools.
- Use 'relative margin of error' for rme; soften the amplification claim.
- Link Timestamp Providers section to reduce duplication; add FAQ to README Docs.
- Measurement-precision intro: a fully timer-saturated distribution does
  not reliably inflate rme, so drop the "high margin of error" framing and
  point to the authoritative signals instead — the 'warning' event and
  Task.detectedResolution (README Timer Diagnostics section).
- auto provider: align wording with the README ("most precise available").
- Decouple diagnostics: detectedResolution is exposed on every run, while
  the 'warning' event is dispatched only on timer saturation (task.ts).
- Precision mitigation: prefer the 'warning' event / detectedResolution as
  the reliable saturation signal; note rme is only a soft hint (it can be
  either very high or very low under saturation, utils.ts rme=moe/|mean|).
- Name the now option as a plain-millisecond alternative to timestampProvider
  (mutually exclusive, converted internally).
- JIT deopt: reframe DevTools as added overhead / disabled optimizations
  rather than a deopt cause.
Reflect that detectedResolution is undefined when no positive timer sample
was measured (e.g. every sample overridden), matching the README Timer
Diagnostics wording (task.ts sets it per valid run, undefined otherwise).
Remove the timestampProvider code example that duplicated the README
Timestamp Providers section near-verbatim (including the trailing comment);
link to that section for the example instead, to avoid maintenance drift.

@jerome-benoit jerome-benoit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Docs-only PR (new FAQ.md + a README Docs link), reviewed line-by-line against the current default branch (main @ 0647d27, including the #571 timer-overhead/saturation/resolution feature):

  • timestampProvider shorthands (hrtimeNow/performanceNow/bunNanoseconds/auto), the auto per-runtime selection, and the now option (plain-ms function, converted internally, mutually exclusive with timestampProvider) all match the code (src/utils.ts, src/bench.ts, src/types.ts).
  • detectedResolution (exposed on each valid run, undefined otherwise) and the 'warning' saturation event are described as implemented (src/task.ts); rme is correctly the relative margin of error, and the FAQ correctly notes it is only a soft hint (a saturated task can report a very high or very low rme).
  • Warmup on-by-default and excluded from the reported statistics; the cited Statistics fields all exist.
  • Both README anchors (#timer-diagnostics, #timestamp-providers) resolve.

All review threads have been addressed and resolved. No code changes.

@jerome-benoit
jerome-benoit merged commit 0ac0a77 into tinylibs:main Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Documentation: add FAQ.md

2 participants