Skip to content

fix: use performance.now() instead of Date.getTime() for timing - #156

Open
pedrocruz-seon wants to merge 1 commit into
theajack:masterfrom
pedrocruz-seon:fix-performance-now-timing
Open

fix: use performance.now() instead of Date.getTime() for timing#156
pedrocruz-seon wants to merge 1 commit into
theajack:masterfrom
pedrocruz-seon:fix-performance-now-timing

Conversation

@pedrocruz-seon

@pedrocruz-seon pedrocruz-seon commented Aug 14, 2026

Copy link
Copy Markdown

Summary

calculateTime() used Date.getTime(), which test frameworks, fake timers, and some APM tools commonly patch. A constant override collapses every measurement to 0, so the === 0 guard in detect() bails out every tick and the detector is silently disabled.

Fix

Prefer performance.now() (with a Date.getTime() fallback). It uses the browser's monotonic clock, is harder to stub into a stable constant, and avoids the 1ms floor that made those === 0 guards necessary.

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.

1 participant