Skip to content
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

doc: update process.hrtime docs to include optional parameter #6585

Closed

Conversation

doug-wade
Copy link
Contributor

Checklist
  • tests and code linting passes
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

process

Description of change

Adds more explicit documentation for the single optional parameter to process.hrtime to the process docs. See #6571 for context.

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label May 4, 2016
@@ -745,7 +745,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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes. Looks like my text editor stripped trailing spaces; I'm guessing they're important, so I'll fix the commit real quick.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you they have been inserted erroneously. Since other lines below have none I would prefer to have it "fixed" now. @jasnell do you have an opinion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well... two trailing spaces in markdown means line break. though it's one of the most stupid things I've ever heard of, so don't worry about it.

@doug-wade doug-wade force-pushed the fix-6571-process-hrtime-docs branch from 773e99b to bf51815 Compare May 5, 2016 00:03
@mscdex mscdex added the process Issues and PRs related to the process subsystem. label May 5, 2016
@jasnell
Copy link
Member

jasnell commented May 5, 2016

LGTM thank you!

@jasnell
Copy link
Member

jasnell commented May 6, 2016

@nodejs/documentation

@eljefedelrodeodeljefe
Copy link
Contributor

Good one! LGTM and thanks.

@ChALkeR
Copy link
Member

ChALkeR commented May 6, 2016

Please note the discussion here: #4757 (comment)

If we document it that way, it could become ambiguous of what should happen in corner cases, i.e. when the time is not a result of a previous call to process.hrtime(), but is e.g. larger than the output that process.hrtime() would have produced.

/cc @trevnorris, @bnoordhuis

@doug-wade
Copy link
Contributor Author

@ChALkeR your suggestion is to make it more explicit that you could get negative times, or other strange behaviors, if you try to construct a time array by hand?

@trevnorris
Copy link
Contributor

If it's clearly documented what the array should be (a return from a previous hrtime() call) then we can say that any other array is simply UB. I'm fine w/ that.

@doug-wade doug-wade force-pushed the fix-6571-process-hrtime-docs branch from bf51815 to 092da04 Compare May 13, 2016 00:31
@jasnell
Copy link
Member

jasnell commented May 17, 2016

@trevnorris ... any further thoughts on this?
@doug-wade ... just fyi, we don't get notified automatically when commits are updated.

@doug-wade
Copy link
Contributor Author

@jasnell thanks for the heads' up. I'll be more proactive about mentioning reviewers in the future.

@jasnell
Copy link
Member

jasnell commented May 17, 2016

No worries :-)

@trevnorris
Copy link
Contributor

@jasnell basically that if the array has a negative value, etc., then the returning array will have garbage numbers in it. we only make a guarantee about what the return value should be if the input values match what we expect. anything else is UB. so we don't have to put in a bunch of pointless type/range checks.

@doug-wade
Copy link
Contributor Author

@trevnorris I added the following verbiage

Constructing an array by some method other than calling `process.hrtime()` and
passing the result to process.hrtime() will result in undefined behavior.

in addition to the original specification

`time` is an optional parameter that must be the result of a
previous `process.hrtime` call

Does that sufficiently address your concern?

@trevnorris
Copy link
Contributor

@doug-wade That reads excellent. Allows us to keep the existing implementation.

@doug-wade
Copy link
Contributor Author

@jasnell anything else I need to do before I merge?

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.htime() (we typically add the () when mentioning function names)

@jasnell
Copy link
Member

jasnell commented May 20, 2016

One small additional nit but otherwise LGTM

@eljefedelrodeodeljefe
Copy link
Contributor

Still LGTM w/ @jasnell nits addressed and one extra comment.

Adds more explicit documentation for the single optional parameter
to process.hrtime to the process docs.
@doug-wade doug-wade force-pushed the fix-6571-process-hrtime-docs branch from 092da04 to 6c221dc Compare May 20, 2016 22:22
@doug-wade
Copy link
Contributor Author

@jasnell fixed up the missing parens nit

@jasnell
Copy link
Member

jasnell commented May 21, 2016

LGTM!

@ChALkeR
Copy link
Member

ChALkeR commented May 21, 2016

LGTM

@trevnorris
Copy link
Contributor

Thanks for the changes. LGTM

@jasnell jasnell changed the title [6571] Update process.hrtime docs to include optional parameter doc: update process.hrtime docs to include optional parameter May 27, 2016
jasnell pushed a commit that referenced this pull request May 27, 2016
Adds more explicit documentation for the single optional parameter
to process.hrtime to the process docs.

PR-URL: #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>
@jasnell
Copy link
Member

jasnell commented May 27, 2016

Landed in e916218

@jasnell jasnell closed this May 27, 2016
@mscdex
Copy link
Contributor

mscdex commented May 27, 2016

I just noticed this commit contains a reference to process.hrtime() without backticks (towards the end of the diff).

Fishrock123 pushed a commit to Fishrock123/node that referenced this pull request May 30, 2016
Adds more explicit documentation for the single optional parameter
to process.hrtime to the process docs.

PR-URL: nodejs#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>
rvagg pushed a commit that referenced this pull request Jun 2, 2016
Adds more explicit documentation for the single optional parameter
to process.hrtime to the process docs.

PR-URL: #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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. process Issues and PRs related to the process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants