diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-06-11 17:37:09 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-06-17 22:34:58 +0800 |
commit | 1d8a23173311337d93c365cba3357ac6f87eb39c (patch) | |
tree | a9518b91613f80cc5b7db530a66dea3d4578d619 /doc | |
parent | 54ee8cb5dd28e9e72770ee4ab6aa73d700232cb5 (diff) | |
download | android-node-v8-1d8a23173311337d93c365cba3357ac6f87eb39c.tar.gz android-node-v8-1d8a23173311337d93c365cba3357ac6f87eb39c.tar.bz2 android-node-v8-1d8a23173311337d93c365cba3357ac6f87eb39c.zip |
process: implement process.hrtime.bigint()
PR-URL: https://github.com/nodejs/node/pull/21256
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/process.md | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/api/process.md b/doc/api/process.md index 16116a3206..e6612278b6 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1159,6 +1159,9 @@ added: v0.7.6 * `time` {integer[]} The result of a previous call to `process.hrtime()` * Returns: {integer[]} +This is the legacy version of [`process.hrtime.bigint()`][] +before `bigint` was introduced in JavaScript. + The `process.hrtime()` method returns the current high-resolution real time in a `[seconds, nanoseconds]` tuple `Array`, where `nanoseconds` is the remaining part of the real time that can't be represented in second precision. @@ -1187,6 +1190,33 @@ setTimeout(() => { }, 1000); ``` +## process.hrtime.bigint() +<!-- YAML +added: REPLACEME +--> + +* Returns: {bigint} + +The `bigint` version of the [`process.hrtime()`][] method returning the +current high-resolution real time in a `bigint`. + +Unlike [`process.hrtime()`][], it does not support an additional `time` +argument since the difference can just be computed directly +by subtraction of the two `bigint`s. + +```js +const start = process.hrtime.bigint(); +// 191051479007711n + +setTimeout(() => { + const end = process.hrtime.bigint(); + // 191052633396993n + + console.log(`Benchmark took ${end - start} nanoseconds`); + // Benchmark took 1154389282 nanoseconds +}, 1000); +``` + ## process.initgroups(user, extraGroup) <!-- YAML added: v0.9.4 @@ -2030,6 +2060,8 @@ cases: [`process.execPath`]: #process_process_execpath [`process.exit()`]: #process_process_exit_code [`process.exitCode`]: #process_process_exitcode +[`process.hrtime()`]: #process_process_hrtime_time +[`process.hrtime.bigint()`]: #process_process_hrtime_bigint [`process.kill()`]: #process_process_kill_pid_signal [`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn [`promise.catch()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch |