Skip to content

fix(performance-monitor-plugin): 1ms-precise time display#269

Merged
V3RON merged 1 commit into
callstackincubator:mainfrom
burczu:fix/performance-monitor-plugin-time-display-precision
May 14, 2026
Merged

fix(performance-monitor-plugin): 1ms-precise time display#269
V3RON merged 1 commit into
callstackincubator:mainfrom
burczu:fix/performance-monitor-plugin-time-display-precision

Conversation

@burczu
Copy link
Copy Markdown
Contributor

@burczu burczu commented May 14, 2026

Summary

  • formatDuration no longer fakes precision: ms values round to integer (.toFixed(2) was fabricating 0.01ms detail the clock can't provide), >= 1s values show 3 decimals (1.234s) for the same 1ms-precision invariant, and non-zero sub-1ms values display as <1ms to distinguish "fired but fast" from "not measured." Rounding happens before the unit switch, so 999.6ms displays as 1.000s rather than 1000ms.
  • formatTime now produces a stable 24h HH:MM:SS.mmm format — the millisecond component is visible alongside HH:MM:SS on every "Recorded at" / "Started" / "Start Time" / "End Time" line across Mark / Metric / Measure / Resource / ReactNativeMark / SessionDuration.
  • Cleanup: three inline formatTime duplicates in MarkDetails, MetricDetails, and SessionDuration replaced with imports from utils. ResourceDetails.formatPhase keeps its 0/undefined → "—" special case but routes non-zero values through formatDuration so resource timing phases honor the same precision rule. SessionDuration keeps its own whole-second formatDuration for the always-ticking session-length display.

Test plan

  • pnpm --filter @rozenite/performance-monitor-plugin test — all 26 tests pass (10 new utils.test.ts + 16 existing for serialize/derive-startup-phases).
  • pnpm --filter @rozenite/performance-monitor-plugin typecheck — clean.
  • pnpm --filter @rozenite/performance-monitor-plugin lint — clean.
  • Manual: in the Performance Monitor panel, verify every "Recorded at" / "Started" / "Start Time" / "End Time" timestamp renders as HH:MM:SS.mmm (24h, three-digit ms padding).
  • Manual: Measure Duration column shows integer ms for sub-1s values and 1.234s style for ≥1s.
  • Manual: a performance.mark that fires near-instantly displays as <1ms, not 0ms.
  • Manual: SessionDuration's "Duration" line continues to tick whole-second values (intentionally untouched).

…splay

formatDuration drops fake decimals for milliseconds — clock is 1ms
accurate, so .toFixed(2) was fabricating precision. Durations >= 1s
display 3 decimals (1.234s) to preserve the same 1ms precision in
seconds. Non-zero sub-millisecond values render as "<1ms" to
distinguish "fired but fast" from "not measured." Rounding now
happens before unit selection, so 999.6ms displays as 1.000s rather
than 1000ms.

formatTime now produces a stable 24h HH:MM:SS.mmm format so the
millisecond component is visible alongside HH:MM:SS in the Mark /
Metric / Measure / Resource / ReactNativeMark details panels and on
the session-started line.

Inline formatTime duplicates in MarkDetails, MetricDetails, and
SessionDuration are replaced with imports from utils so the new
format propagates everywhere. SessionDuration keeps its own
whole-second formatDuration for the always-ticking session-length
display. ResourceDetails.formatPhase keeps its 0/undefined → "—"
special case but routes non-zero values through formatDuration so
resource timing phases honor the same precision rule.

Adds vitest tests covering the boundary behaviors (zero, sub-1ms,
ms rounding, ms/s switch at 1000, round-across-boundary at 999.6,
ms padding, midnight, end-of-day).
@V3RON V3RON merged commit 0442184 into callstackincubator:main May 14, 2026
1 check passed
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.

2 participants