-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
process: implement process.hrtime.bigint() #21256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
process: implement process.hrtime.bigint()
- Loading branch information
commit 30533c7f3c4a06c842fb3dcfb8d1de61bf280280
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1187,6 +1187,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 substraction 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. benchmark -> Benchmark? |
||
| }, 1000); | ||
| ``` | ||
|
|
||
| ## process.initgroups(user, extraGroup) | ||
| <!-- YAML | ||
| added: v0.9.4 | ||
|
|
@@ -2030,6 +2057,7 @@ cases: | |
| [`process.execPath`]: #process_process_execpath | ||
| [`process.exit()`]: #process_process_exit_code | ||
| [`process.exitCode`]: #process_process_exitcode | ||
| [`process.hrtime()`]: #process_process_hrtime_time | ||
| [`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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| 'use strict'; | ||
|
|
||
| // Tests that process.hrtime.bigint() works. | ||
|
|
||
| require('../common'); | ||
| const assert = require('assert'); | ||
|
|
||
| const start = process.hrtime.bigint(); | ||
| assert.strictEqual(typeof start, 'bigint'); | ||
|
|
||
| const end = process.hrtime.bigint(); | ||
| assert.strictEqual(typeof end, 'bigint'); | ||
|
|
||
| assert(end - start >= 0n); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subtraction