doc: update process.hrtime docs to include optional parameter

Adds more explicit documentation for the single optional parameter
to process.hrtime to the process docs.

PR-URL: https://github.com/nodejs/node/pull/6585
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This commit is contained in:
doug.wade 2016-05-04 16:35:14 -07:00 committed by James M Snell
parent 6306b10c48
commit e916218ba5

View File

@ -798,7 +798,7 @@ added: v0.1.13
* `code` {Integer} The exit code. Defaults to `0`. * `code` {Integer} The exit code. Defaults to `0`.
The `process.exit()` method instructs Node.js to terminate the process as The `process.exit()` method instructs Node.js to terminate the process as
quickly as possible with the specified exit `code`. If the `code` is omitted, quickly as possible with the specified exit `code`. If the `code` is omitted,
exit uses either the 'success' code `0` or the value of `process.exitCode` if exit uses either the 'success' code `0` or the value of `process.exitCode` if
specified. specified.
@ -811,7 +811,7 @@ process.exit(1);
The shell that executed Node.js should see the exit code as `1`. The shell that executed Node.js should see the exit code as `1`.
It is important to note that calling `process.exit()` will force the process to It is important to note that calling `process.exit()` will force the process to
exit as quickly as possible *even if there are still asynchronous operations exit as quickly as possible *even if there are still asynchronous operations
pending* that have not yet completed fully, *including* I/O operations to pending* that have not yet completed fully, *including* I/O operations to
`process.stdout` and `process.stderr`. `process.stdout` and `process.stderr`.
@ -820,8 +820,8 @@ explicitly. The Node.js process will exit on it's own *if there is no additional
work pending* in the event loop. The `process.exitCode` property can be set to work pending* in the event loop. The `process.exitCode` property can be set to
tell the process which exit code to use when the process exits gracefully. tell the process which exit code to use when the process exits gracefully.
For instance, the following example illustrates a *misuse* of the For instance, the following example illustrates a *misuse* of the
`process.exit()` method that could lead to data printed to stdout being `process.exit()` method that could lead to data printed to stdout being
truncated and lost: truncated and lost:
```js ```js
@ -863,7 +863,7 @@ A number which will be the process exit code, when the process either
exits gracefully, or is exited via [`process.exit()`][] without specifying exits gracefully, or is exited via [`process.exit()`][] without specifying
a code. a code.
Specifying a code to [`process.exit(code)`][`process.exit()`] will override any Specifying a code to [`process.exit(code)`][`process.exit()`] will override any
previous setting of `process.exitCode`. previous setting of `process.exitCode`.
@ -947,15 +947,18 @@ if (process.getuid) {
} }
``` ```
## process.hrtime() ## process.hrtime([time])
<!-- YAML <!-- YAML
added: v0.7.6 added: v0.7.6
--> -->
Returns the current high-resolution real time in a `[seconds, nanoseconds]` Returns the current high-resolution real time in a `[seconds, nanoseconds]`
tuple Array. It is relative to an arbitrary time in the past. It is not tuple Array. `time` is an optional parameter that must be the result of a
related to the time of day and therefore not subject to clock drift. The previous `process.hrtime()` call (and therefore, a real time in a
primary use is for measuring performance between intervals. `[seconds, nanoseconds]` tuple Array containing a previous time) to diff with
the current time. These times are relative to an arbitrary time in the past,
and not related to the time of day and therefore not subject to clock drift.
The primary use is for measuring performance between intervals.
You may pass in the result of a previous call to `process.hrtime()` to get You may pass in the result of a previous call to `process.hrtime()` to get
a diff reading, useful for benchmarks and measuring intervals: a diff reading, useful for benchmarks and measuring intervals:
@ -973,6 +976,9 @@ setTimeout(() => {
}, 1000); }, 1000);
``` ```
Constructing an array by some method other than calling `process.hrtime()` and
passing the result to process.hrtime() will result in undefined behavior.
## process.initgroups(user, extra_group) ## process.initgroups(user, extra_group)
<!-- YAML <!-- YAML