Skip to content

Commit

Permalink
doc: update process.hrtime docs to include optional parameter
Browse files Browse the repository at this point in the history
Adds more explicit documentation for the single optional parameter
to process.hrtime to the process docs.

PR-URL: #6585
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Robert Jefe Lindstaedt <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
  • Loading branch information
doug-wade authored and rvagg committed Jun 2, 2016
1 parent 0f17a28 commit 7c38327
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ added: v0.1.13
* `code` {Integer} The exit code. Defaults to `0`.

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
specified.

Expand All @@ -811,7 +811,7 @@ process.exit(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
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
`process.stdout` and `process.stderr`.

Expand All @@ -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
tell the process which exit code to use when the process exits gracefully.

For instance, the following example illustrates a *misuse* of the
`process.exit()` method that could lead to data printed to stdout being
For instance, the following example illustrates a *misuse* of the
`process.exit()` method that could lead to data printed to stdout being
truncated and lost:

```js
Expand Down Expand Up @@ -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
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`.


Expand Down Expand Up @@ -947,15 +947,18 @@ if (process.getuid) {
}
```

## process.hrtime()
## process.hrtime([time])
<!-- YAML
added: v0.7.6
-->

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
related to the time of day and therefore not subject to clock drift. The
primary use is for measuring performance between intervals.
tuple Array. `time` is an optional parameter that must be the result of a
previous `process.hrtime()` call (and therefore, a real time in a
`[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
a diff reading, useful for benchmarks and measuring intervals:
Expand All @@ -973,6 +976,9 @@ setTimeout(() => {
}, 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)
<!-- YAML
Expand Down

0 comments on commit 7c38327

Please sign in to comment.