-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
process.cpuUsage accuracy #8728
Copy link
Copy link
Closed
Labels
processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.questionIssues that look for answers.Issues that look for answers.
Metadata
Metadata
Assignees
Labels
processIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.questionIssues that look for answers.Issues that look for answers.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I'm trying to find cpu utilization of the process as a percentage of the system as a whole - similar to how top, activity monitor, and similar tools work, but from within the program itself. It appears that process.cpuUsage is a relatively new feature, and I haven't been able to find a way to get the cpu percentage and have it accurately match values found in system monitors. I created a repository of some of the different methods I have tried: https://github.com/nickstanish/node-test-process-cpuusage
It appears that there is discussion on an approach to get the percentage, but uses the wrong precision and seems to not account for number of cpu cores.
Is there a recommended approach in order to find this value?
I'd also like to point out that the tests for this feature have the wrong precision as well which makes the possible value range huge. The process usage values are in microseconds and it multiplies by 1e6
https://github.com/nodejs/node/blob/master/test/pummel/test-process-cpuUsage.js#L27
Original Issue:
nodejs/help#283