From 0497b2c79bec5da5164d16770e991b67e102d86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 18 Nov 2024 10:13:45 +0100 Subject: [PATCH] fix: use performance.now() for timestamping with node MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The high resolution timer brings noticiable overhead. Signed-off-by: Jérôme Benoit --- src/time.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/time.js b/src/time.js index 010fc4d..29643ec 100644 --- a/src/time.js +++ b/src/time.js @@ -32,8 +32,8 @@ export const now = (() => { } }, node: () => { - const hrtimeBigint = process.hrtime.bigint.bind(process.bigint) - return () => Number(hrtimeBigint()) + const now = performance.now.bind(performance) + return () => 1e6 * now() }, deno: () => { const now = performance.now.bind(performance)