Uh oh!
There was an error while loading. Please reload this page.
process.cpuUsage() - implementation, doc, tests - #6157
Conversation
pmuellr
commented
Apr 11, 2016
See discussion from original PR #5565 |
addaleax
commented
Apr 11, 2016
Hm, is there any concrete advantage to splitting up the 64-bit numbers into two lanes and reassembling them in JS? Like, wouldn’t using a |
eljefedelrodeodeljefe
commented
Apr 11, 2016
Awesome. LGTM with nits. |
pmuellr
commented
Apr 11, 2016
@addaleax I copied the style of |
addaleax
commented
Apr 11, 2016
@pmuellr Sounds reasonable – was just wondering because it seemed a little odd :) |
mhdawson
commented
Apr 11, 2016
I'd suggest a CI run so that we confirm uv_getrusage is fully supported across all platforms(should be). Otherwise we might need to add info in that respect to the docs. I can't tell if you can do that so I launched one for you: |
eljefedelrodeodeljefe
commented
Apr 11, 2016
Should be fine. On Windows only those two fields this PR is using are populated. The unices share the same function, but don't populate same results for some fields. nit: The inline comment could be rephrased, omitting the part that |
Fishrock123
commented
Apr 12, 2016
cc @mscdex who appears to have primarily reviewed the previous PR. |
mscdex
commented
Apr 12, 2016
I didn't really review the last PR, I was mostly just seeing if there was interest in having a separate Just briefly looking over this PR, I'm wondering if it might just be better to drop the extra |
There was a problem hiding this comment.
Just a style nit...
if(_cpuUsage(cpuValues)!==0)thrownewError('unable to obtain cpu usage time');jasnell
commented
Apr 12, 2016
I'd be +1 on not having the additional |
There was a problem hiding this comment.
definitely use const wherever possible :-)
jasnell
commented
Apr 12, 2016
Generally LGTM with a few nits. |
Fishrock123
commented
Apr 12, 2016
@pmuellr I'd probably just make the commit message something like |
pmuellr
commented
Apr 12, 2016
@mhdawson that build is green, so guess it passes muster? |
pmuellr
commented
Apr 12, 2016
My usual excuse here - I copied from |
pmuellr
commented
Apr 12, 2016
I think the argument comes down to aligning w/ I'm siding with making life easier for users. |
mscdex
commented
Apr 12, 2016
@pmuellr What does aligning with |
pmuellr
commented
Apr 12, 2016
I've added the proposed commit message in the header of this PR. Currently: process: add The Drive-by fix to process.hrtime() doc to align with preferred non-usage of "you" |
pmuellr
commented
Apr 12, 2016
@mscdex ah, yes, forgot to mention that One expected uses of Whenever you're dealing with |
mscdex
commented
Apr 12, 2016
@pmuellr Right, but what I meant was users are not going to be doing I think I am still -1 on artificially adjusting the cpu usage values. |
pmuellr
commented
Apr 12, 2016
@mscdex yes, correct, you'd never mix/match values from Still think there's value in having a shared model for these, so you can have a single (tuple) -> value conversion fn that works with both. But it's not a deal-breaker for me or anything. |
There was a problem hiding this comment.
Comments should be capitalized and punctuated.
| argument to the function, to get a diff reading. | ||
| ```js | ||
| const startUsage = process.cpuUsage(); |
* fixed whitespace issue on doc/api/process.md * improved test in test/parallel/test-process-cpuUsage.js, as below: changed: assert(result.user != null); assert(result.system != null); to: assert.notEqual(result, null); The next tests below the original asserts called Number.isFinite() on the fields in result, which also return false on null/undefined check, so the removed asserts were dups. But realized we weren't actually checking the result parameter for null/undefined.
pmuellr
commented
Apr 29, 2016
Thanks for the comments @santigimeno . Pushed a new commit. Using |
santigimeno
commented
Apr 29, 2016
jasnell
commented
Apr 29, 2016
CI looks good except for unrelated build bot failure (passed previously on that bot). Landing... |
Add process.cpuUsage() method that returns the user and system CPU time usage of the current process PR-URL: #6157 Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
jasnell
commented
Apr 29, 2016
pmuellr
commented
Apr 29, 2016
Thanks everyone! Great way to end the week. |
Add process.cpuUsage() method that returns the user and system CPU time usage of the current process PR-URL: #6157 Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Add process.cpuUsage() method that returns the user and system CPU time usage of the current process PR-URL: nodejs#6157 Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
* assert: `deep{Strict}Equal()` now works correctly with circular
references. (Rich Trott) #6432
* debugger: Arrays are now formatted correctly in the debugger repl.
(cjihrig) #6448
* deps: Upgrade OpenSSL sources to 1.0.2h (Shigeki Ohtsu)
#6550
* net: Introduced a `Socket#connecting` property. (Fedor Indutny)
#6404
- Previously this information was only available as the undocumented,
internal `_connecting` property.
* process: Introduced `process.cpuUsage()`. (Patrick Mueller)
#6157
* stream: `Writable#setDefaultEncoding()` now returns `this`.
(Alexander Makarenko) #5040
* util: Two new additions to `util.inspect()`:
- Added a `maxArrayLength` option to truncate the formatting of
Arrays. (James M Snell) #6334
- This is set to `100` by default.
- Added a `showProxy` option for formatting proxy intercepting
handlers. (James M Snell) #6465
- Inspecting proxies is non-trivial and as such this is off by
default.
PR-URL: #6557* assert: `deep{Strict}Equal()` now works correctly with circular
references. (Rich Trott) #6432
* debugger: Arrays are now formatted correctly in the debugger repl.
(cjihrig) #6448
* deps: Upgrade OpenSSL sources to 1.0.2h (Shigeki Ohtsu)
#6550
- Please see our blog post for more info on the security contents of this release:
- https://nodejs.org/en/blog/vulnerability/openssl-may-2016/
* net: Introduced a `Socket#connecting` property. (Fedor Indutny)
#6404
- Previously this information was only available as the undocumented,
internal `_connecting` property.
* process: Introduced `process.cpuUsage()`. (Patrick Mueller)
#6157
* stream: `Writable#setDefaultEncoding()` now returns `this`.
(Alexander Makarenko) #5040
* util: Two new additions to `util.inspect()`:
- Added a `maxArrayLength` option to truncate the formatting of
Arrays. (James M Snell) #6334
- This is set to `100` by default.
- Added a `showProxy` option for formatting proxy intercepting
handlers. (James M Snell) #6465
- Inspecting proxies is non-trivial and as such this is off by
default.
PR-URL: #6557* assert: `deep{Strict}Equal()` now works correctly with circular
references. (Rich Trott) #6432
* debugger: Arrays are now formatted correctly in the debugger repl.
(cjihrig) #6448
* deps: Upgrade OpenSSL sources to 1.0.2h (Shigeki Ohtsu)
#6550
- Please see our blog post for more info on the security contents of
this release:
- https://nodejs.org/en/blog/vulnerability/openssl-may-2016/
* net: Introduced a `Socket#connecting` property. (Fedor Indutny)
#6404
- Previously this information was only available as the undocumented,
internal `_connecting` property.
* process: Introduced `process.cpuUsage()`. (Patrick Mueller)
#6157
* stream: `Writable#setDefaultEncoding()` now returns `this`.
(Alexander Makarenko) #5040
* util: Two new additions to `util.inspect()`:
- Added a `maxArrayLength` option to truncate the formatting of
Arrays. (James M Snell) #6334
- This is set to `100` by default.
- Added a `showProxy` option for formatting proxy intercepting
handlers. (James M Snell) #6465
- Inspecting proxies is non-trivial and as such this is off by
default.
PR-URL: #6557Add process.cpuUsage() method that returns the user and system CPU time usage of the current process PR-URL: nodejs#6157 Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Backport to v4.x Original commit message: Add process.cpuUsage() method that returns the user and system CPU time usage of the current process PR-URL: #6157 Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> PR-URL: #10796 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Backport to v4.x Original commit message: Add process.cpuUsage() method that returns the user and system CPU time usage of the current process PR-URL: #6157 Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> PR-URL: #10796 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Backport to v4.x Original commit message: Add process.cpuUsage() method that returns the user and system CPU time usage of the current process PR-URL: #6157 Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> PR-URL: #10796 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Checklist
make -j4 lint test)current planned commit message
process: add
cpuUsage()The
cpuUsage()function will return user and system CPU usage timings for thecurrent process.
Drive-by fix to process.hrtime() doc to align with preferred non-usage of "you"
in function description.
Affected core subsystem(s)
processmoduleDescription of change
add the function
cpuUsage()toprocess