diff options
author | snek <snek@deno.com> | 2024-11-08 23:20:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-08 23:20:24 +0100 |
commit | 73fbd61bd016eebbf2776dc94c15a26bf39668d6 (patch) | |
tree | c7e5f4ee47f94f2279e745b1825959f82a66a22d /runtime/js/99_main.js | |
parent | d4f1bd3dacf54c4625eef7828341b39286ead8cb (diff) |
fix: performance.timeOrigin (#26787)
`performance.timeOrigin` was being set from when JS started executing,
but `op_now` measures from an `std::time::Instant` stored in `OpState`,
which is created at a completely different time. This caused
`performance.timeOrigin` to be very incorrect. This PR corrects the
origin and also cleans up some of the timer code.
Compared to `Date.now()`, `performance`'s time origin is now
consistently within 5us (0.005ms) of system time.

Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r-- | runtime/js/99_main.js | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 4d391dcc3..6ddaa1335 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -27,7 +27,6 @@ const { ArrayPrototypeForEach, ArrayPrototypeIncludes, ArrayPrototypeMap, - DateNow, Error, ErrorPrototype, FunctionPrototypeBind, @@ -642,7 +641,7 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { removeImportedOps(); - performance.setTimeOrigin(DateNow()); + performance.setTimeOrigin(); globalThis_ = globalThis; // Remove bootstrapping data from the global scope @@ -858,7 +857,7 @@ function bootstrapWorkerRuntime( 7: nodeDebug, } = runtimeOptions; - performance.setTimeOrigin(DateNow()); + performance.setTimeOrigin(); globalThis_ = globalThis; // Remove bootstrapping data from the global scope |