Description
- v6.3.1:
- Darwin Kernel Version 15.6.0 root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64:
- process:
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