diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2022-08-28 12:21:49 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-28 12:21:49 +0530 |
commit | d8396225c4287c53dd42226266e9f66983125e51 (patch) | |
tree | 27516437c40b80596f4d0fc9b821882a0f2a0ca1 /ext/web/02_timers.js | |
parent | 7c4f57e8b091bc386242f83b5373e4bb33382012 (diff) |
perf: use fast api for op_now (#15643)
Diffstat (limited to 'ext/web/02_timers.js')
-rw-r--r-- | ext/web/02_timers.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ext/web/02_timers.js b/ext/web/02_timers.js index 07b9587ea..f703120e6 100644 --- a/ext/web/02_timers.js +++ b/ext/web/02_timers.js @@ -13,6 +13,7 @@ MapPrototypeGet, MapPrototypeHas, MapPrototypeSet, + Uint32Array, // deno-lint-ignore camelcase NumberPOSITIVE_INFINITY, PromisePrototypeThen, @@ -25,8 +26,14 @@ const { reportException } = window.__bootstrap.event; const { assert } = window.__bootstrap.infra; + let hr; function opNow() { - return ops.op_now(); + if (!hr) { + hr = new Uint32Array(2); + ops.op_now_set_buf(hr); + } + ops.op_now.fast(); + return (hr[0] * 1000 + hr[1] / 1e6); } // --------------------------------------------------------------------------- |