Skip to content

feat(test): show sub-millisecond test durations#35200

Open
lunadogbot wants to merge 2 commits into
mainfrom
claude/deno-issue-30785-j2egml
Open

feat(test): show sub-millisecond test durations#35200
lunadogbot wants to merge 2 commits into
mainfrom
claude/deno-issue-30785-j2egml

Conversation

@lunadogbot

Copy link
Copy Markdown
Contributor

Problem

Test durations under 1ms were truncated to 0ms in the test reporter output, because the elapsed time was converted with duration.as_millis() as u64 before reaching the reporters. This made fast tests look like they took no time at all:

OrderStatusHistoryMapper → toDto should map entity to DTO ... ok (1ms)
OrderStatusHistoryMapper → toDtoArray should map multiple entities to an array ... ok (0ms)

Closes #30785

Changes

Following the maintainer's guidance in the issue, the full Duration is now threaded through the test pipeline instead of being pre-truncated to milliseconds:

  • TestEvent::Result, Slow, and StepResult now carry a Duration instead of u64 milliseconds.
  • The reporter trait (and all reporters: pretty, dot, tap, junit, compound, plus the LSP test reporter) now take a Duration.
  • display::human_elapsed now accepts a Duration and renders sub-millisecond durations in microseconds (µs) or nanoseconds (ns), matching the units already used by the deno bench reporter. Output for durations ≥ 1ms is unchanged.
  • The JUnit reporter now records more precise timings as well (it previously rounded to whole milliseconds).

After the change:

fast sync test ... ok (18ms)
tiny map test ... ok (278µs)
noop ... ok (145µs)

Notes

  • Test steps still report at millisecond resolution because they are timed in JS via Date.now(). That was left out of scope to keep this change focused on the top-level test durations the issue is about; the millisecond value is converted to a Duration at the op boundary so there's no behavior change there.
  • Existing spec tests match the timing field with ([WILDCARD]), so they remain compatible.

Tests

  • Added test_human_elapsed_sub_millisecond covering the ns/µs/ms boundaries, and updated test_human_elapsed for the new signature.

https://claude.ai/code/session_012SJDri5NiiSbGVrYq6hsNQ


Generated by Claude Code

claude added 2 commits June 13, 2026 15:49
Test durations under 1ms were truncated to 0ms in the test reporter
output, making fast tests look like they took no time at all.

Thread the full `Duration` through `TestEvent` and the reporter trait
instead of truncating to integer milliseconds, and render sub-millisecond
durations with fractional millisecond precision (e.g. `0.523ms`). This
also gives the JUnit reporter more precise timings.

Closes #30785

https://claude.ai/code/session_012SJDri5NiiSbGVrYq6hsNQ
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.

Show more decimal places for tests that take less than 1 ms

2 participants