diff options
author | Gus Caplan <me@gus.host> | 2020-05-28 00:10:22 -0500 |
---|---|---|
committer | Gus Caplan <me@gus.host> | 2020-06-06 11:55:45 -0500 |
commit | d8eef83757c263672832687ac7667927a7d0c059 (patch) | |
tree | 8c4a9697dc1bbfa041ae211f961a87ebcffa7b5a /lib/internal/process/per_thread.js | |
parent | e983b1cece7d24f7b4776798916276d30b9e419a (diff) | |
download | node-new-d8eef83757c263672832687ac7667927a7d0c059.tar.gz |
process: use v8 fast api calls for hrtime
Refs: https://github.com/nodejs/node/issues/33374
PR-URL: https://github.com/nodejs/node/pull/33600
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/internal/process/per_thread.js')
-rw-r--r-- | lib/internal/process/per_thread.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index d219cd7298..303e71703d 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -41,7 +41,6 @@ function assert(x, msg) { function wrapProcessMethods(binding) { const { hrtime: _hrtime, - hrtimeBigInt: _hrtimeBigInt, cpuUsage: _cpuUsage, memoryUsage: _memoryUsage, resourceUsage: _resourceUsage @@ -113,10 +112,10 @@ function wrapProcessMethods(binding) { // The 3 entries filled in by the original process.hrtime contains // the upper/lower 32 bits of the second part of the value, // and the remaining nanoseconds of the value. - const hrValues = new Uint32Array(3); + const hrValues = new Uint32Array(_hrtime.buffer); function hrtime(time) { - _hrtime(hrValues); + _hrtime.hrtime(); if (time !== undefined) { if (!ArrayIsArray(time)) { @@ -140,9 +139,9 @@ function wrapProcessMethods(binding) { // Use a BigUint64Array in the closure because this is actually a bit // faster than simply returning a BigInt from C++ in V8 7.1. - const hrBigintValues = new BigUint64Array(1); + const hrBigintValues = new BigUint64Array(_hrtime.buffer, 0, 1); function hrtimeBigInt() { - _hrtimeBigInt(hrBigintValues); + _hrtime.hrtimeBigInt(); return hrBigintValues[0]; } |