Skip to content

Commit

Permalink
remove usage of performance.timeOrigin (#2921)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Jun 4, 2024
1 parent 6ba6d26 commit 8c5d280
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-islands-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

remove usage of performance.timeOrigin
7 changes: 1 addition & 6 deletions packages/effect/src/internal/clock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,10 @@ export const globalClockScheduler: Clock.ClockScheduler = {

const performanceNowNanos = (function() {
const bigint1e6 = BigInt(1_000_000)

if (typeof performance === "undefined") {
return () => BigInt(Date.now()) * bigint1e6
}

const origin = "timeOrigin" in performance && typeof performance.timeOrigin === "number" ?
BigInt(Math.round(performance.timeOrigin * 1_000_000)) :
(BigInt(Date.now()) * bigint1e6) - BigInt(Math.round(performance.now() * 1_000_000))

const origin = (BigInt(Date.now()) * bigint1e6) - BigInt(Math.round(performance.now() * 1_000_000))
return () => origin + BigInt(Math.round(performance.now() * 1_000_000))
})()
const processOrPerformanceNow = (function() {
Expand Down

0 comments on commit 8c5d280

Please sign in to comment.