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

CPU utilization is not accurate #499

Closed
Z-SmallRock opened this issue Feb 25, 2021 · 2 comments
Closed

CPU utilization is not accurate #499

Z-SmallRock opened this issue Feb 25, 2021 · 2 comments

Comments

@Z-SmallRock
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. used function 'currentLoad'

Expected behavior
When I use currentLoad to get the currentLoad variable it has a value but it's a little bit different from the task manager's CPU statistics so what's wrong with that Looking forward to your reply

Environment (please complete the following information):

  • systeminformation package version:5.0.7
  • OS: [win10]
@sebhildebrandt
Copy link
Owner

@zhaoxiaolei519109457 I will have a look at it but I am pretty much sure, that the way I am calculating this is the only possible way within node. I am aware of slightly different values to task manager but it is still accurate to the numbers that I get from os.cpus() where we exactly have values for user, system, nice, irq and idle ticks per CPU core. I have to rely on those ticks when calculating the currentLoad.

Just to be sure: calling currentLoad() the first time will not have correct values. You need to call it multiple times to get the load between the calls (as documented in https://systeminformation.io/statsfunctions.html).

In your case it should be something like:

const si = require('systeminformation');

setInterval(function() {
    si.currentLoad().then(data => {
        console.log(data);
    })
}, 1000)

Hope that helps.

@sebhildebrandt
Copy link
Owner

Testet it once again, and the method I am calculating it seems to be correct. I got the same values as in activity monitor (+/- 1% ... ) ... If you have an idea, what can be improved here, I would be happy to get further comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants